Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Installing Windows Features on remote server 2012

$
0
0

I am wondering which is best practice considering both examples will probably work. Using the built in help examples I have written a script to install windows features on remote servers. Here is my code:

 $servers = ('server1', 'server2', 'server3', 'server4')

    ForEach ($server in $servers) {
        Install-WindowsFeature -Name Desktop-Experience -ComputerName $server -IncludeAllSubFeature -IncludeManagementTools -Restart
    }

Would the above be preferred OR should I wrap the "Install-WindowsFeature ..." in an "Invoke-Command" block like the following?

 Invoke-Command -ComputerName server1, server2, server3, server4 -command {
        Install-WindowsFeature -Name Desktop-Experience -ComputerName $server -IncludeAllSubFeature -IncludeManagementTools -Restart
    }


Thanks for your insight!


Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>