PowerShell Remote
Run PowerShell Scripts on Remote Computers in Lan Network.
Prerequisite
The remote computers must have PowerShell remoting enabled
(WinRM) and a user account with sufficient permissions on the remote
machines is required
Enable WinRM in Remote PC
Run CMD or PowerShell with Admin rights
Run this command with admin privileges ‘winrm quickconfig –y’
Prepare list of Computer to Execute
Script.
Prepare a list of computer names or IPs from the LanSweeper
Add the list in PowerShell Script variable
Command to Execute Script.
Invoke-Command -ComputerName $computerNames -ScriptBlock { script code }
Also ensure that port number 5985 should be open on remote computer.
Command to Execute Script.
# Run the script on each computer asynchronously Invoke-Command -
ComputerName $computerNames -AsJob -ScriptBlock { # your script code }
# Process computers in batches of 20 $computerNames | ForEach-Object
{ Invoke-Command -ComputerName $_ -ScriptBlock { # your script code } }
Local Machine PS
PSSession Invoke-Command
‘Use WinRM’
Authenticated via Kerberos Logged-In successfully on remote pc
“CredSSP” to access network resources
Run “\\rbi-d-349\ScanEDD\Windows 10 Upgrade New-2-Final.ps1"
Client Side Commands:
1. Enable-WinRM Quickconfig
Yes
2. Enable-PSRemoting –Force
3. Enable-WSManCredSSP –Role Server
Local Machine Side Commands:
Same as Remote Machine Command but
Use
Enable-WSManCredSSP -Role Client -DelegateComputer "MEN-D-331"