A set of cmdlets that runs the same PowerShell cmdlets for multiple remote servers.
Please put source in any directory.
cd C:\path\to\RemotePowerShell\dir
git clone git@github.com:SunriseDigital/RemotePowerShell.git
To load files automatically when PowerShell is started you need to enable $profile.
Please open the terminal of PowerShell and check the $ profile file exists.
test-path $profileIf the result is False, create a $profile file with the following command.
new-item -path $profile -itemtype file -forceYou can check the path of the $ profile file with $profile.
PS > $profile
C:\Path\To\Microsoft.PowerShell_profile.ps1Edit the $profile as below.
Get-ChildItem "C:\path\to\RemotePowerShell\dir\scripts\*.ps1" | %{.$_}If you want to reload, you can restart the shell or with . $profile.
First, copy include \ servers.ps1.tpl and change the name to servers.ps1.
Copy-Item C:\path\to\RemotePowerShell\dir\scripts\include\servers.ps1.tpl C:\path\to\RemotePowerShell\dir\scripts\include\servers.ps1And, added server settgins to servers.ps1
$servers = $(
(new-object RPS.Server "Administrator", "**Administrator password**", "192.168.0.1", "test")
)- Login user name.
- Login user password.
- Server address.
- Server name.
Do not forget to reload.
. $profileYou can confirm server setting with the following command.
Get-RPSServer
User Password Address Name
---- -------- ------- ----
Administrator **Administrator 192.168.0.1 test- For safety, set 5985 port of the firewall of the destination server so that it can connect only from a specific remote IP address.
Get-NetFirewallPortFilter | ? {$_.LocalPort -eq 5985 -and $_.Protocol -eq "TCP"} | Get-NetFirewallRule | ? {$_.Direction –eq "Inbound"} | Set-NetFirewallRule -RemoteAddress ***.***.***.***- Execute the following cmdlet and select
Yfor all options. You need administrator privileges.
Enable-PSRemoting- Register the IP address of the destination server in TrustedHosts of the source PC.
Set-Item WSMan:\localhost\Client\TrustedHosts -Value ***.***.***.***If you want to know the details of the cmdlet, please use Get-Help.
Get-Help Get-RPSServer -full- Copy-RPSWebsite
- Enter-RPSSession
- Format-RPSList
- Get-RPSNetFirewallAddressFilter
- Get-RPSNetFirewallApplicationFilter
- Get-RPSNetFirewallPortFilter
- Get-RPSNetFirewallRule
- Get-RPSServer
- Get-RPSWebApplication
- Get-RPSWebAppPool
- Get-RPSWebsite
- New-RPSNetFirewallRule
- Remove-RPSNetFirewallRule
- Restart-RPSWebAppPool
- Set-RPSNetFirewallRule