I faced the task to create some scripts which perform a backup on our Microsoft Windows Server 2008 systems used for user acceptance testing. Before each deployment, a backup of the currently deployed database and applications should happen. Our database is based on Microsoft SQL Server 2008 and our applications are built on Microsoft ASP.NET and Microsoft Internet Information Services 7. Since we have several servers for testing, I wanted to create a solution, which allows me to upload scripts to the remote system and then execute them afterwards. This seemed to be the perfect case for Microsoft Windows PowerShell, since the Remoting feature allows me to do exactly that – upload a script and execute it.
PowerShell Remoting allows you to communicate with remote systems and execute PowerShell scripts on them. You can even run the same script on several systems at the same time.
To setup PowerShell Remoting, you have to conduct the following steps:
- On the server: Enable remoting:
PS C:\> Enable-PSRemoting
- On the client: Switch to the WSMAN section:
PS C:\> cd wsman:\localhost\Client
- On the client: Add the server to the list of trusted hosts:
PS WSMan:\localhost\Client> Set-Item TrustedHosts -Value * -force
- On the client: Allow data to be transferred unencrypted between client and server:
PS WSMan:\localhost\Client> Set-Item AllowUnencrypted -Value $true -force
For increased security you can of course force https to be used as transport protocol. Moreover, you can limit the trusted hosts to the IP/hostname you really need (* means every host is allowed to connect).
Latest posts by André (see all)
- How To Configure IPSec VPN on pfSense For Use With iPhone, iPad, Android, Windows and Linux - September 14, 2014
- How to Enable Sonic Ether’s Unbelievable Shaders for Minecraft 1.7.10 - July 30, 2014
- Book Review “Crypto” - July 11, 2014