forked from Azure/AgentBaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Windows VHD pipeline tests (Azure#429)
- Loading branch information
Showing
2 changed files
with
41 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Stop and remove Azure Agents to enable use in Azure Stack | ||
# If deploying an Azure VM the agents will be re-added to the VMs at deployment time | ||
Stop-Service WindowsAzureGuestAgent | ||
Stop-Service WindowsAzureNetAgentSvc | ||
Stop-Service RdAgent | ||
& sc.exe delete WindowsAzureGuestAgent | ||
& sc.exe delete WindowsAzureNetAgentSvc | ||
& sc.exe delete RdAgent | ||
|
||
# Remove the WindowsAzureGuestAgent registry key for sysprep | ||
# This removes AzureGuestAgent from participating in sysprep | ||
# There was an update that is missing VMAgentDisabler.dll | ||
$path = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\SysPrepExternal\Generalize" | ||
$generalizeKey = Get-Item -Path $path | ||
$generalizeProperties = $generalizeKey | Select-Object -ExpandProperty property | ||
$values = $generalizeProperties | ForEach-Object { | ||
New-Object psobject -Property @{"Name"=$_; | ||
"Value" = (Get-ItemProperty -Path $path -Name $_).$_} | ||
} | ||
|
||
$values | ForEach-Object { | ||
$item = $_; | ||
if( $item.Value.Contains("VMAgentDisabler.dll")) { | ||
Write-HOST "Removing " $item.Name - $item.Value; | ||
Remove-ItemProperty -Path $path -Name $item.Name; | ||
} | ||
} | ||
|
||
# run Sysprep | ||
if( Test-Path $Env:SystemRoot\\system32\\Sysprep\\unattend.xml ) { Remove-Item $Env:SystemRoot\\system32\\Sysprep\\unattend.xml -Force } | ||
& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /mode:vm /quiet /quit | ||
|
||
# when done clean up | ||
while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10 } else { break } } | ||
Get-ChildItem c:\\WindowsAzure -Force | Sort-Object -Property FullName -Descending | ForEach-Object { try { Remove-Item -Path $_.FullName -Force -Recurse -ErrorAction SilentlyContinue; } catch { } } | ||
Remove-Item -Path WSMan:\\Localhost\\listener\\listener* -Recurse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters