-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path1080.ps1
More file actions
51 lines (43 loc) · 1.78 KB
/
Copy path1080.ps1
File metadata and controls
51 lines (43 loc) · 1.78 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
###############################################################################
#
# Get all servers from a OU and run GPUpdate /force on this machines.
#
# Version 1.0
#
# (C) 2009 - Arne Fokkema
# www.ict-freak.nl
#
# Install the Quest AD cmdlets first!!
#
###############################################################################
# Requires QAD cmdlets
if ((Get-PSSnapin "Quest.ActiveRoles.ADManagement" `
-ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin "Quest.ActiveRoles.ADManagement"
}
$url = "http://live.sysinternals.com/psexec.exe"
$target = "c:\Tools\psexec.exe"
$TempFile = "C:\Machines.txt"
$Domain = Read-Host ("Enter the FQDN of the Domain")
$OU = Read-Host ("Enter the name of the OU")
# Check if psexec does exist
if (test-path $target)
{
write-host "psexec.exe is already installed"
}
else
{
write-host "psexec.exe doesn't exist"
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($url, $target);
write-host "psexec.exe is now installed"
}
$Servers = Get-QADComputer -SearchRoot $Domain/$OU | Select Name | out-file $TempFile -force
#Cleanup Textfile
(Get-Content $TempFile) | Foreach-Object {$_ -replace "Name ", ""} | Set-Content $TempFile
(Get-Content $TempFile) | Foreach-Object {$_ -replace "---- ", ""} | Set-Content $TempFile
(Get-Content $TempFile) | Foreach-Object {$_ -replace " ", ""} | Set-Content $TempFile
(Get-Content $TempFile) | where {$_ -ne ""} >$TempFile
$colComputers = Get-Content $TempFile
Foreach ($strComputer in $colComputers){c:\Tools\psexec.exe \\$strComputer gpupdate.exe /target:computer /force}
RM $TempFile