Give this a try and let me know if it resolves the issue. I would add where are using pulling the variable $PCName.text? This would have to be accounted for.
Give this a try and let me know if it resolves the issue. I would add where are using pulling the variable $PCName.text? This would have to be accounted for.
just tested on my machine (be careful here as you also need to think about how to clear the stale pssessions)
but the following worked:
[pre]
Start-Process -FilePath PowerShell.exe -ArgumentList “-NoExit -NoLogo -Command New-PSSession $PCName.txt; enter-pssession $PCName.txt”
[/pre]
It depends on how you are passing the data. The $PCName isn’t going to work well becasue its not part of the powershell environment. You will need to set this and write it out. Also you don’t need to use New-PSSEssion if you are going to enter it as well, just go ahead and enter it. What commands are you looking to run once the session is started? You may be better off with Invoke-Command.