Powershell Remoting is an excellent feature which can be exploit by everyone. But it has its limitation. At work, I need of building a solution that would automate a manual process for our IT staff. In this case, I had to create a Powershell script (psscript) that will allow me to copy a file in the user desktop for later retrieval without interrupting his work. So, I decided to use Powershell Remoting features using the CMDLET “Invoke-Expression” ran some with/without the “-runspace” switch.
Here’s what I found out :
1. If you have the need to passing strings parameters, no spaces are allowed. Exception – when using the “-runspace” parameter with “dir” commands. You might have a folder name with spaces “’My Documents”. In this case you need to add the single quote in the string, sample $dirName = “’My Documents’”.
2. You can’t use the “-credential” parameter past invoking the psscript on another computer. I mean, if within the script you is trying to copy a file to a network folder, the credential only work for executing the script.
3. When using the “-runspace” parameter make sure to use the “Remove-Runspace” CMDLET or the connection to the computer stays active.
So, as you can see, there some limitations in using this feature. But, it doesn’t leave dead in the water. You still can run script remotely as long as it contains no spaces, it must run local on the remote computer, and you can use the *-PSjob CMDLET to run in the background of the remote computer. This coming Tuesday March 11th I will be speaking about "Powershell 2.0 CTP Remoting features". I will have my presentation and samples available later.