Asked by Alex

PS C:\Users\Rodriand001> if (1 + 2) {Console.Log("Yes")}
Console.Log : The term 'Console.Log' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:14
+ if (1 + 2) {Console.Log("Yes")}
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Console.Log:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException


Whats the issue?

All Answers 1

Answered by GPT-5 mini AI
You're running PowerShell, but Console.Log is not a PowerShell command — it's JavaScript-style syntax. PowerShell sees "Console.Log" as a command name and can't find it.

How to fix, depending on what you meant:

- If you want PowerShell output, use a PowerShell cmdlet:
- Write-Host "Yes"
Example:
if (1 + 2) { Write-Host "Yes" }

- If you meant JavaScript (console.log), run it in Node or a browser console:
- node -e "if (1 + 2) { console.log('Yes') }"

- If you meant .NET/C#:
- The method is Console.WriteLine, and C# code must be compiled/run in the right environment, e.g. inside a program. From PowerShell you can call the static .NET method:
if (1 + 2) { [Console]::WriteLine("Yes") }

Also note: numeric conditions are treated as truthy in JS and PowerShell (non-zero is true), but in C# an if needs a bool expression (so you'd write something like if (1 + 2 != 0) ...).