Call PowerShell script PS1 from another PS1 script inside Powershell ISE

I want call execution for a myScript1.ps1 script inside a second myScript2.ps1 script inside Powershell ISE. The following code inside MyScript2.ps1, works fine from Powershell Administration, but doesn’t work inside PowerShell ISE: #Call myScript1 from myScript2 invoke-expression -Command .\myScript1.ps1 I obtain the following error when I execute MyScript2.ps1 from PowerShell ISE: The term ‘.\myScript1.ps1’ is … Read more

PowerShell and the -contains operator

Consider the following snippet: “12-18” -Contains “-” You’d think this evaluates to true, but it doesn’t. This will evaluate to false instead. I’m not sure why this happens, but it does. To avoid this, you can use this instead: “12-18”.Contains(“-“) Now the expression will evaluate to true. Why does the first code snippet behave like … Read more

What’s the difference between “Write-Host”, “Write-Output”, or “[console]::WriteLine”?

There are a number of different ways to output messages. What is the effective difference between outputting something via Write-Host, Write-Output, or [console]::WriteLine? I also notice that if I use: write-host “count=” + $count The + gets included in the output. Why’s that? Shouldn’t the expression be evaluated to produce a single concatenated string before … Read more