GPOGuid
$SourceGPO = "ABC8823c-379e-4b4d-a5ff-8c94cdad9424"
$rootPaths= "HKCU\\Software"
$ArrayData=@()
$Getdetails = Get-GPRegistryValue -guid $SourceGPO -Key $rootPaths -Verbose -ErrorAction Stop
function Get-MyGPORegistry ($Getdetails){
foreach ($Member in $Getdetails) {
try {
# write-host DIVE - $Member.FullKeyPath
if ([string]::IsNullOrEmpty($Member.PolicyState) ) {
$Getdetails= Get-GPRegistryValue -guid $SourceGPO -Key $member.FullKeyPath -Verbose -ErrorAction Stop
Get-MyGPORegistry -Getdetails $Getdetails
} else{
$Member.FullKeyPath
$global:ArrayData+=$member # HAS TO BE A BETTER WAY
}
} catch {}
}
}
Get-MyGPORegistry -getdetails $Getdetails
$ArrayData | Export-Csv -Path C:\\users\\panda\\Desktop\\gporegistry.csv -NoTypeInformation
$internetSettings=$ArrayData|?{ $_.Fullkeypath -match "Internet Settings"}
$DestinationGPO = "ABC9F8C3-C06F-4996-937D-97FA75F66307"
foreach ($value in $internetSettings){
# Assumes PolicyState = "Set" would require rewrite for "Delete"
Write-Verbose "SETTING SET [$($Value.FullKeyPath):$($Value.Valuename)]"
$Value | Set-GPRegistryValue -guid $DestinationGPO -Verbose
}