Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions RegistryXML/Import-RegistryXML.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ Write-Host ""
# Gather Registry XML
#======================================================================================
$GPOPreferences = Get-ChildItem "$ScriptDirectory\ImportXML" *.xml -Recurse
if ($ProductName -like "*Windows 7*") {$GPOPreferences = $GPOPreferences | Where-Object {$_.FullName -NotLike "*Win10*"}}
if ($ProductName -like "*Windows 10*") {$GPOPreferences = $GPOPreferences | Where-Object {$_.FullName -NotLike "*Win7*"}}
if ($ProductName -like "*Windows 7*") {$GPOPreferences = $GPOPreferences | Where-Object {$_.FullName -NotLike "*Win10*" -and $_.FullName -NotLike "*WinServ*"}}
if ($ProductName -like "*Windows 10*") {$GPOPreferences = $GPOPreferences | Where-Object {$_.FullName -NotLike "*Win7*" -and $_.FullName -NotLike "*WinServ*"}}
if ($ProductName -like "*Windows Server*") {$GPOPreferences = $GPOPreferences | Where-Object {$_.FullName -NotLike "*Win7*" -and $_.FullName -NotLike "*Win10*"}}
#======================================================================================
# Import Registry XML
Expand Down Expand Up @@ -226,7 +226,7 @@ if (!($GPOPreferences)) {
if ($RegAction -eq "D") {
if ($RegDefault -eq '0' -and $RegName -eq '' -and $RegValue -eq '') {
Write-Host "Remove-Item -LiteralPath $RegPath" -ForegroundColor Red
Remove-Item -LiteralPath $RegPath -Force
Remove-Item -LiteralPath $RegPath -Force -Recurse -Confirm:$False
} elseif ($RegDefault -eq '1') {
Write-Host "Remove-ItemProperty -LiteralPath $RegPath" -ForegroundColor Red
Write-Host "-Name '(Default)'"
Expand All @@ -241,7 +241,7 @@ if (!($GPOPreferences)) {
if (Test-Path -Path "HKLM:\MountedAdministrator") {
Write-Host "Remove-ItemProperty -LiteralPath $RegPathAdmin" -ForegroundColor Red
if ($RegDefault -eq '0' -and $RegName -eq '' -and $RegValue -eq '') {
Remove-ItemProperty -LiteralPath $RegPathAdmin -Force
Remove-Item -LiteralPath $RegPathAdmin -Force -Recurse -Confirm:$False
} elseif ($RegDefault -eq '1') {
Write-Host "-Name '(Default)'"
Remove-ItemProperty -LiteralPath $RegPathAdmin -Name '(Default)' -Force
Expand All @@ -253,7 +253,7 @@ if (!($GPOPreferences)) {
if (Test-Path -Path "HKLM:\MountedDefaultUser") {
Write-Host "Remove-ItemProperty -LiteralPath $RegPathDUser" -ForegroundColor Red
if ($RegDefault -eq '0' -and $RegName -eq '' -and $RegValue -eq '') {
Remove-ItemProperty -LiteralPath $RegPathDUser -Force
Remove-Item -LiteralPath $RegPathDUser -Force -Recurse -Confirm:$False
} elseif ($RegDefault -eq '1') {
Write-Host "-Name '(Default)'"
Remove-ItemProperty -LiteralPath $RegPathDUser -Name '(Default)' -Force
Expand Down Expand Up @@ -326,4 +326,4 @@ if (!($GPOPreferences)) {
# Read-Host -Prompt "Press Enter to Continue"
#======================================================================================
Stop-Transcript
#======================================================================================
#======================================================================================