PowerTip: Run a Remote PowerShell Command in a Disconnected Session

PowerTip: Run a Remote PowerShell Command in a Disconnected Session

  • Comments 2
  • Likes

Summary: Learn how to use the Windows PowerShell 3.0 Invoke-Command cmdlet to create a disconnected session.

Hey, Scripting Guy! Question How can I run a command on a remote computer running Windows PowerShell 3.0 in a disconnected session?

Hey, Scripting Guy! Answer Use the Invoke-Command cmdlet with the Disconnected parameter, as shown here. Note that icm is an alias for Invoke-Command.

icm -ComputerName dc2 -ScriptBlock {1..20 | %{get-date;gps;sleep 600} } -Disconnected

 

 

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • very useful.

  • @Serhad Makbuloglu Thank you. The ability to work in disconnected sessions in PowerShell 3.0 is a cool new feature.