We have all heard this quote before… and it is exactly true. However in your server environment, when you want things identical, then we would turn this phrase around:
Insanity: Doing things manually over and over and expecting identical results.
I have not spent a great deal of time learning PowerShell… but whenever I have a task to do, such as installing a role or a feature, I try to do it with PowerShell. I actually leverage another of Einstein’s great axioms:
The Internet is a great tool for this… I can look up nearly anything I need, especially with regard to PowerShell.
So previously, when I wanted to install a role on multiple servers I would run a series of cmdlets:
PS C:\>Install-WindowsFeature Failover-Clustering –IncludeManagementTools –ComputerName Server1
PS C:\>Install-WindowsFeature Failover-Clustering –IncludeManagementTools –ComputerName Server2
PS C:\>Install-WindowsFeature Failover-Clustering –IncludeManagementTools –ComputerName Server3
Of course, this would work perfectly. However recently I was looking up one of the cmdlets I needed on the Internet and stumbled across an easier way to do it… and especially when I want to run a series of identical cmdlets across the multiple servers. I can simply create a multi-server session. Watch:
PS C:\>$session=New-PSSession –ComputerName Server1,Server2,Server3
PS C:\>Invoke-Command –session $session {Add-WindowsFeature Failover-Clustering –IncludeManagementTools}
Two lines instead of three doesn’t really make my life a lot easier… but let’s say I was doing more than simply adding a role… this could save me a lot of time and, more importantly, ensure uniformity across my servers.
Creating a PSSession is great for things like initial configuration of servers… think of all of the tasks you perform on every server in your organization… or even just every web server, or file server. This will work for Firewall rules, and any number of other settings you can think of.
Try it out… It will save you time going forward!
Leave a Reply