Created
April 3, 2020 22:28
-
-
Save adbertram/72c9728b7cd2b055902cd13dbdfef1ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Define each computer you'd like to run the install on | |
$computers = 'COMP1','COMP2','COMP3' | |
## This is the path that contains the installer file for the software you'd like to install on the servers | |
$softwarePath = '\\MEMBERSRV1\Software' | |
## Read each of the computers in the $computers array defined above | |
foreach ($pc in $computers) { | |
## Copy \\MEMBERSRV1\Software to each target computers' C:\Windows\Temp folder | |
Copy-Item -Path $softwarePath -Destination "\\$pc\c$\Windows\Temp" | |
## Run an install.msi file that should be $softwarePath. This file gets copied from the source folder to each | |
## server's temp folder. This runs msiexec locally on each server in the foreach loop | |
## "Software" in the path is the folder name from \\MEMBERSRV1\Software | |
Invoke-Command –ComputerName $pc –ScriptBlock {msiexec /I "C:\Windows\Temp\Software\install.msi" /qn} | |
## Remove the Software folder copied to the server after the install is done | |
Remove-Item -Path "\\$pc\c$\Windows\Temp\Software" -Recurse -Force | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment