--- step
initialize
--- hostctl
{"host": "ssh://admin@dhcp01:22?shell=powershell&pathname=windows&timeout=120", "password": false, "script": "$ErrorActionPreference = 'Stop'/n$p = ConvertFrom-Json '{/"Commands/": [{/"Args/": [/"dhcp/", /"server/", /"////////dhcp01/", /"scope/", /"10.0.0.0/", /"delete/", /"reservedip/", /"10.0.0.10/", /"aabbccddeeff/"], /"Ignore/": true}, {/"Args/": [/"dhcp/", /"server/", /"////////dhcp01/", /"scope/", /"10.0.0.0/", /"add/", /"reservedip/", /"10.0.0.10/", /"aabbccddeeff/", /"web01/", /"netboot/", /"BOTH/"], /"Ignore/": false}, {/"Args/": [/"dhcp/", /"server/", /"////////dhcp01/", /"scope/", /"10.0.0.0/", /"set/", /"reservedoptionvalue/", /"10.0.0.10/", /"3/", /"IPADDRESS/", /"10.0.0.1/"], /"Ignore/": false}, {/"Args/": [/"dhcp/", /"server/", /"////////dhcp01/", /"scope/", /"10.0.0.0/", /"set/", /"reservedoptionvalue/", /"10.0.0.10/", /"6/", /"IPADDRESS/", /"10.0.0.53/", /"10.0.0.54/"], /"Ignore/": false}, {/"Args/": [/"dhcp/", /"server/", /"////////dhcp01/", /"scope/", /"10.0.0.0/", /"set/", /"reservedoptionvalue/", /"10.0.0.10/", /"15/", /"STRING/", /"example.com/"], /"Ignore/": false}, {/"Args/": [/"dhcp/", /"server/", /"////////dhcp01/", /"scope/", /"10.0.0.0/", /"set/", /"reservedoptionvalue/", /"10.0.0.10/", /"1/", /"IPADDRESS/", /"255.255.255.0/"], /"Ignore/": false}, {/"Args/": [/"dhcp/", /"server/", /"////////dhcp01/", /"scope/", /"10.0.0.0/", /"set/", /"reservedoptionvalue/", /"10.0.0.10/", /"28/", /"IPADDRESS/", /"10.0.0.255/"], /"Ignore/": false}, {/"Args/": [/"dhcp/", /"server/", /"////////dhcp01/", /"scope/", /"10.0.0.0/", /"set/", /"reservedoptionvalue/", /"10.0.0.10/", /"67/", /"STRING/", /"undionly.kpxe/"], /"Ignore/": false}], /"IPAddress/": /"10.0.0.10/", /"Verify/": [{/"Id/": /"3/", /"Count/": 1}, {/"Id/": /"6/", /"Count/": 2}, {/"Id/": /"15/", /"Count/": 1}, {/"Id/": /"1/", /"Count/": 1}, {/"Id/": /"28/", /"Count/": 1}, {/"Id/": /"67/", /"Count/": 1}], /"VerifyArgs/": [/"dhcp/", /"server/", /"////////dhcp01/", /"scope/", /"10.0.0.0/", /"dump/"]}'/nforeach ($c in $p.Commands) {/n  $a = @($c.Args)/n  $out = & netsh @a 2>&1 | Out-String/n  Write-Verbose $out/n  if ($LASTEXITCODE -ne 0 -and -not $c.Ignore) {/n    throw /"netsh $($c.Args -join ' ') failed ($LASTEXITCODE): $out/"/n  }/n}/nif ($p.Verify) {/n  $d = @($p.VerifyArgs)/n  $dump = (& netsh @d 2>&1 | Out-String) -split /"`r?`n/"/n  $bad = @()/n  foreach ($v in $p.Verify) {/n    $re = 'set reservedoptionvalue//s+' + [regex]::Escape($p.IPAddress) +/n          '//s+' + $v.Id + '//s'/n    $line = $dump | Where-Object { $_ -match $re } | Select-Object -First 1/n    if (-not $line) { $bad += /"option $($v.Id) was not applied/"; continue }/n    $tail = $line -replace ('^.*' + $re), ''/n    $tail = $tail -replace '^//S+//s*', ''/n    $n = @([regex]::Matches($tail, '/"[^/"]*/"|//S+')).Count/n    if ($n -lt $v.Count) {/n      $bad += /"option $($v.Id) kept $n of $($v.Count) values/"/n    }/n  }/n  if ($bad) {/n    throw /"netsh reported success but the server disagrees: /" +/n          ($bad -join '; ')/n  }/n}/nConvertTo-Json @{ ok = $true }/n"}
--- step
complete
--- hostctl
{"host": "ssh://admin@dhcp01:22?shell=powershell&pathname=windows&timeout=120", "password": false, "script": "$ErrorActionPreference = 'Stop'/n$p = ConvertFrom-Json '{/"Commands/": [{/"Args/": [/"dhcp/", /"server/", /"////////dhcp01/", /"scope/", /"10.0.0.0/", /"delete/", /"reservedip/", /"10.0.0.10/", /"aabbccddeeff/"], /"Ignore/": true}]}'/nforeach ($c in $p.Commands) {/n  $a = @($c.Args)/n  $out = & netsh @a 2>&1 | Out-String/n  Write-Verbose $out/n  if ($LASTEXITCODE -ne 0 -and -not $c.Ignore) {/n    throw /"netsh $($c.Args -join ' ') failed ($LASTEXITCODE): $out/"/n  }/n}/nConvertTo-Json @{ ok = $true }/n"}
