What is `$?` in Powershell?

It returns true if the last command was successful, else false. However, there are a number of caveats and non-obvious behaviour (e.g. what exactly is meant by “success”). I strongly recommend reading this article for a fuller treatment. For example, consider calling Get-ChildItem. PS> Get-ChildItem PS> $? True $? will return True as the call … Read more

dotnet ef scaffold Unrecognized option ‘-t firstTable -t secondTable’ – pass arguments stored in a string

If you construct a string such as -t foo and pass it via a variable to an external program, it is passed as a single, double-quoted argument (that is, donet will literally see “-t foo” on its command line) – and therefore won’t be recognized as parameter name-value combination. You must pass -t and foo … Read more

Are you able to use PtrToStringAuto to decrypt a secure string in Powershell 7 on macOS?

Note that [securestring] is not recommended for new code anymore. While on Windows secure strings offer limited protection – by storing the string encrypted in memory – via the DPAPI – and by shortening the window during which the plain-text representation is held in memory, no encryption at all is used on Unix-like platforms.[1] The … Read more

Can you redirect Tee-Object to standard out?

To complement zett42’s helpful answer: If you’re running PowerShell (Core) 7+, you can pass the file path that represents the terminal (console) to the (positionally implied) -FilePath parameter (in Windows PowerShell, this causes an error, unfortunately – see bottom section): # PowerShell 7+ only # Windows Get-Content data.txt | Tee-Object \\.\CON | data_processor.exe # Unix-like … Read more