-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoteCopyInstall.ps1
More file actions
60 lines (43 loc) · 2.31 KB
/
Copy pathRemoteCopyInstall.ps1
File metadata and controls
60 lines (43 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<#
** THIS SCRIPT IS PROVIDED WITHOUT WARRANTY, USE AT YOUR OWN RISK **
.SYNOPSIS
Copy an install package to 1 or more computers and install silently
.DESCRIPTION
Reads a txt file containing computer names and attempts to ping each machine
If the ping is successful, Copy the contents of c:\Install from the source computer
to c:\install on the target machine. Once the copy is complete test that the install
package is present (in my case the Adobe Reader DC offline installer) and then launch
the installation silently with no reboot or user interaction required.
This example uses the Adobe Reader install package but it can easily be modified
to install other software packages.
.REQUIREMENTS
1. The appropriate rights to ping and copy on the remote machine.
2. A computers.txt file with a list of computer names
3. PowerShell remoting enabled if the target is a client OS
4. Appropriate permissions on the target machine to install software
.NOTES
Tested with Windows 10 source and Windows Server 2K12 R2 target
.AUTHOR
David Hall | http://www.signalwarrant.com/
.LINK
Adobe reader DC download: http://ardownload.adobe.com/pub/adobe/reader/win/AcrobatDC/1501020060/AcroRdrDC1501020060_en_US.exe
#>
# This is the file that contains the list of computers you want
# to copy the folder and files to. Change this path IAW your folder structure.
$computers = Get-Content "C:\scripts\computers.txt"
# This is the directory you want to copy to the computer (IE. c:\folder_to_be_copied)
$source = "c:\install"
# On the desination computer, where do you want the folder to be copied?
$dest = "c$"
$testPath = "c:\install\AcroRdrDC1501020060_en_US.exe"
foreach ($computer in $computers) {
if (test-Connection -Cn $computer -quiet) {
Copy-Item $source -Destination \\$computer\$dest -Recurse -Force
if (Test-Path -Path $testPath) {
Invoke-Command -ComputerName $computer -ScriptBlock {powershell.exe c:\Install\AcroRdrDC1501020060_en_US.exe /sAll /msi /norestart ALLUSERS=1 EULA_ACCEPT=YES}
Write-Host -ForegroundColor Green "Installation successful on $computer"
}
} else {
Write-Host -ForegroundColor Red "$computer is not online, Install failed"
}
}