Skip to content

Commit bd0c8f8

Browse files
committed
verify that the winrm and sshd service are configured to automatic start delayed
verify after using the base image and after executing sysprep
1 parent ae09f4c commit bd0c8f8

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

example/Vagrantfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ Vagrant.configure(2) do |config|
127127
'*.box']
128128
end
129129

130-
#config.vm.provision "windows-sysprep" # NB the windows-sysprep plugin does not work with hyperv.
130+
config.vm.provision "shell", path: "ps.ps1", args: ["assert-service-automatic-start-delayed.ps1", "WinRM", "sshd"]
131+
config.vm.provision "windows-sysprep" # NB the windows-sysprep plugin does not work with hyperv.
132+
config.vm.provision "shell", path: "ps.ps1", args: ["assert-service-automatic-start-delayed.ps1", "WinRM", "sshd"]
131133
config.vm.provision "shell", path: "ps.ps1", args: "expand-os-partition.ps1"
132134
config.vm.provision "shell", path: "ps.ps1", args: "provision-chocolatey.ps1"
133135
config.vm.provision "shell", path: "ps.ps1", args: "provision-adk.ps1"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
param(
2+
[Parameter(Mandatory=$true, ValueFromRemainingArguments=$true)]
3+
[string[]]$serviceNames
4+
)
5+
6+
$serviceNames | ForEach-Object {
7+
$serviceName = $_
8+
# ensure the service is configured as automatic start delayed.
9+
# e.g. START_TYPE : 2 AUTO_START (DELAYED)
10+
$result = sc.exe qc $serviceName | Out-String
11+
if ($result -match '\s+START_TYPE\s+:\s+(?<startTypeId>\d+)\s+(?<startType>\w+)(\s+\((?<startDelayed>\w+)\))?\s+') {
12+
$startType = $Matches['startType']
13+
$startIsDelayed = $Matches['startDelayed'] -eq 'DELAYED'
14+
if ($startType -ne 'AUTO_START' -or -not $startIsDelayed) {
15+
throw "$serviceName start type is not set to automatic start delayed"
16+
}
17+
} else {
18+
throw "failed to parse the sc.exe qc $serviceName output"
19+
}
20+
}

0 commit comments

Comments
 (0)