Thursday, March 13, 2014

Remotely Running PowerShell

Very simple.


To enter a remote PowerShell session:

 enter-pssession servename


To exit the remote session:

 exit-pssession



Commands I like to run remotely:

-Listing and killing an active process:
  (*Particularly any starting with the name "note" and then stopping it)

 get-process -name note*
 stop-process -name note*



-Pulling a system's serial number:
  (*Particularly great for support calls)

 gwmi win32_bios



 This eliminates the need to connect via Remote Desktop in order to perform these simple tasks.


  • [Note] In order to use PowerShell commands on a remote machine: You need to have permission to connect and run these commands remotely; You need to have ran enable-psremoting; You need to have direct communication with the machine; and have opened the firewall in order to connect to the WS Management service. There's more details about of this and these commands listed below.

References:
about_Remote_Requirements, http://technet.microsoft.com/en-us/library/dd315349.aspx
Running Remote Commands, http://technet.microsoft.com/en-us/library/dd819505.aspx
Using the Get-Process Cmdlet, http://technet.microsoft.com/en-us/library/ee176855.aspx
Using the Stop-Process Cmdlet, http://technet.microsoft.com/en-us/library/ee177004.aspx

No comments: