-
Notifications
You must be signed in to change notification settings - Fork 0
/
GP_Install.ps1
23 lines (19 loc) · 1.17 KB
/
GP_Install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# inspired by the custom N-Able AMP I built for my old MSP
#Created by ZJP & AM
Start-Job -ScriptBlock {takeown /f C:\WINDOWS\PolicyDefinitions /r /a; icacls C:\WINDOWS\PolicyDefinitions /grant Administrators:(OI)(CI)F /t; Copy-Item -Path .\Files\PolicyDefinitions\* -Destination C:\Windows\PolicyDefinitions -Force -Recurse -ErrorAction SilentlyContinue}
#Import to Central Store
Foreach ($sysvolpath in Get-ChildItem "C:\Windows\SYSVOL\sysvol") {
New-Item "C:\Windows\SYSVOL\sysvol\$sysvolpath\Policies\PolicyDefinitions\" -Force
Copy-Item -Path "$(Get-Location)\Files\PolicyDefinitions\*" -Destination "C:\Windows\SYSVOL\sysvol\$sysvolpath\Policies\PolicyDefinitions\" -Force -Recurse
}
#Import all manifest exported off our internal DC
$GPOloc = "$(Get-Location)\Files\GPOs"
Foreach ($gpocategory in Get-ChildItem $GPOloc) {
Write-Output "Importing $gpocategory GPOs"
Foreach ($gpo in (Get-ChildItem "$GPOloc\$gpocategory")) {
$gpopath = "$GPOloc\$gpocategory\$gpo"
Write-Output "Importing $gpo"
New-GPO -Name "$gpo" -Comment "built by ZJP"
Import-GPO -BackupGpoName "$gpo" -Path "$gpopath" -TargetName "$gpo" -CreateIfNeeded
}
}