-
Notifications
You must be signed in to change notification settings - Fork 0
/
Training Deploy.ps1
64 lines (64 loc) · 2.21 KB
/
Training Deploy.ps1
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
61
62
63
64
Clear-Host
Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue #This is needed to pull computers from AD
$Skipped = @() #Create Array for Skipped Computers
$Finished = @() #Create Array for Finished Computers
$Offline = @() #Create Array for Offline Computers
$Computers = Get-QADComputer -SearchScope Subtree -SearchRoot "OU=Workstations,DC=local,dc=com" #Get Computers from AD
FOREACH ($Computer in $Computers) #Process Computers
{
$ObjComputerName = New-Object PSObject
$ObjComputerName = $Computer.name
$System = $ObjComputerName
IF (Test-Connection -ComputerName $System -Quiet -Count 1) #Tests to see if computer is online
{
IF (Test-Path "\\$System\C$\Users\Public") #This would indicate Windows 7 OR Vista
{
Copy-Item -Path "C:\Users\Public\Training" -Destination "\\$System\C$\Users\Public" -Recurse -Force
Write-Host "Finished Win7 System $System"
$Finished += $System
}
ELSE
{
IF (Test-Path "\\$System\C$\Documents and Settings\All Users")
{
Copy-Item -Path "C:\Users\Public\Training" -Destination "\\$System\C$\Documents and Settings\All Users" -Recurse -Force
Write-Host "Finished WinXP System $System"
$Finished += $System
}
}
}
ELSE
{
Write-Host "System $System is offline"
$Skipped += $System
}
}
FOREACH ($System in $Skipped) #Process Skipped Computers
{
Write-Host "Retrying Offline System $System"
IF (Test-Connection -ComputerName $System -Quiet -Count 1)
{
IF (Test-Path "\\$System\C$\Users\Public")
{
Copy-Item -Path "C:\Users\Public\Training" -Destination "\\$System\C$\Users\Public" -Recurse -Force
Write-Host "Finished Win7 System $System"
$Finished += $System
}
ELSE
{
IF (Test-Path "\\$System\C$\Documents and Settings\All Users")
{
Copy-Item -Path "C:\Users\Public\Training" -Destination "\\$System\C$\Documents and Settings\All Users" -Recurse -Force
Write-Host "Finished WinXP System $System"
$Finished += $System
}
}
}
ELSE
{
Write-Host "System $System is Offline"
$Offline +=$System
}
}
Write-Host "Offline Systems: $Offline"
Write-Host "Finished Systems: $Finished"