Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. $a = 1
  2. $b = 2
  3. New-PSSession -ComputerName MyRemoteMachineName | Out-Null
  4. Invoke-Command -Session (Get-PSSession) -ArgumentList($a, $b) -ScriptBlock {
  5. $args[0]
  6. $args[1]
  7. }
  8. Get-PSSession | Remove-PSSession
  9.  
  10. $myString = "Something"
  11. New-PSSession -ComputerName MyRemoteComputerName | Out-Null
  12. $outputFromSession = Invoke-Command -Session (Get-PSSession) -ArgumentList($myString) -ScriptBlock {
  13. $args[0] + " " + $env:COMPUTERNAME
  14. }
  15. $outputFromSession
  16. Get-PSSession | Remove-PSSession
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement