Fix error "NoProcessFoundForGivenName" when running Disable-InternetExplorerESC

The error happens because we try to stop the Explorer process which may not running,
so let's check first if the process is running.
This commit is contained in:
Marco Mansi
2020-03-13 21:23:23 +01:00
parent 99478a7e21
commit 9b2f575307
3 changed files with 17 additions and 2 deletions

View File

@@ -36,6 +36,9 @@ $SensitiveData = @(
': ->' ': ->'
) )
Write-Host "Show Packer Version"
packer --version
Write-Host "Build $Image VM" Write-Host "Build $Image VM"
packer build -var "capture_name_prefix=$ResourcesNamePrefix" ` packer build -var "capture_name_prefix=$ResourcesNamePrefix" `
-var "client_id=$ClientId" ` -var "client_id=$ClientId" `

View File

@@ -8,7 +8,13 @@ function Disable-InternetExplorerESC {
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 -Force Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 -Force
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 -Force Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 -Force
Stop-Process -Name Explorer -Force -ErrorAction Continue
$ieProcess = Get-Process -Name Explorer -ErrorAction SilentlyContinue
if ($ieProcess){
Stop-Process -Name Explorer -Force -ErrorAction Continue
}
Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." Write-Host "IE Enhanced Security Configuration (ESC) has been disabled."
} }

View File

@@ -8,7 +8,13 @@ function Disable-InternetExplorerESC {
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 -Force Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 -Force
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 -Force Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 -Force
Stop-Process -Name Explorer -Force -ErrorAction Continue
$ieProcess = Get-Process -Name Explorer -ErrorAction SilentlyContinue
if ($ieProcess){
Stop-Process -Name Explorer -Force -ErrorAction Continue
}
Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." Write-Host "IE Enhanced Security Configuration (ESC) has been disabled."
} }