Skip to content
Merged
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
8 changes: 7 additions & 1 deletion sysprep/sysprep.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ $script:setupscripts_dir_loc = "$env:WinDir\Setup\Scripts"
$script:setupcomplete_loc = "$script:setupscripts_dir_loc\SetupComplete.cmd"
$script:sysprep_output_file_loc = "C:\Windows\System32\Sysprep\Panther\setupact.log"
$script:ggactl = "$gce_install_dir\agent\ggactl_plugin.exe"
$script:mds_creds = "C:\ProgramData\Google\Compute Engine\mds-mtls-*"

# Check if the help parameter was called.
if ($help) {
Expand Down Expand Up @@ -270,13 +271,18 @@ $PSHome\powershell.exe -NoProfile -NoLogo -ExecutionPolicy Unrestricted -File "$
}
}

Write-Log 'Clearing MTLS MDS certs.'
Write-Log 'Clearing MTLS MDS certs from cert store.'
@('Cert:\LocalMachine\My', 'Cert:\LocalMachine\Root') | ForEach-Object {
if (Test-Path $_) {
Get-ChildItem $_ | Where-Object {$_.Issuer -Match 'google.internal'} | Remove-Item
}
}

Write-Log 'Clearing MDS MTLS credentials from disk.'
if (Test-Path $script:mds_creds) {
Remove-Item $script:mds_creds -Recurse -Force -ErrorAction SilentlyContinue
}

if ([System.Environment]::OSVersion.Version.Build -ge 10240) {
Write-Log "Enabling RDP and WinRM firewall rules using PowerShell. Build $([System.Environment]::OSVersion.Version.Build)"
New-NetFirewallRule -DisplayName 'Windows Remote Management (HTTPS-In)' -Direction Inbound -LocalPort 5986 -Protocol TCP -Action Allow -Profile Any
Expand Down