Obtaining ExitCode using Start-Process and WaitForExit instead of -Wait

There are two things to remember here. One is to add the -PassThru argument and two is to add the -Wait argument. You need to add the wait argument because of this defect. -PassThru [<SwitchParameter>] Returns a process object for each process that the cmdlet started. By default, this cmdlet does not generate any output. … Read more

Escaping quotes and double quotes

Using the backtick (`) works fine for me if I put them in the following places: $cmd=”\\server\toto.exe -batch=B -param=`”sort1;parmtxt=”Security ID=1234″`”” $cmd returns as: \\server\toto.exe -batch=B -param=”sort1;parmtxt=”Security ID=1234″” Is that what you were looking for? The error PowerShell gave me referred to an unexpected token ‘sort1’, and that’s how I determined where to put the backticks. … Read more

GetType used in PowerShell, difference between variables

First of all, you lack parentheses to call GetType. What you see is the MethodInfo describing the GetType method on [DayOfWeek]. To actually call GetType, you should do: $a.GetType(); $b.GetType(); You should see that $a is a [DayOfWeek], and $b is a custom object generated by the Select-Object cmdlet to capture only the DayOfWeek property … Read more