Consolidate laboratory network and client maintenance policies
This commit is contained in:
1 parent
bfa520dec8
commit
5cda541e3d
20 files changed
+534
-107
No files matched your search
@@ -13,6 +13,14 @@ foreach ($sid in 'S-1-5-18','S-1-5-32-544') {
|
||||
[Security.Principal.SecurityIdentifier]::new($sid),'FullControl','ContainerInherit,ObjectInherit','None','Allow'))
|
||||
}
|
||||
if((Get-Acl -LiteralPath $destination).GetSecurityDescriptorSddlForm([Security.AccessControl.AccessControlSections]::Access) -ne $acl.GetSecurityDescriptorSddlForm([Security.AccessControl.AccessControlSections]::Access)){Set-Acl -LiteralPath $destination -AclObject $acl}
|
||||
foreach($name in 'ced-network.json','Set-SguCedClientNetwork.ps1'){
|
||||
$source=Join-Path $PSScriptRoot $name
|
||||
$target=Join-Path $destination $name
|
||||
if($source -ine $target -and (-not(Test-Path -LiteralPath $target) -or (Get-FileHash -LiteralPath $source).Hash -ne (Get-FileHash -LiteralPath $target).Hash)){Copy-Item -LiteralPath $source -Destination $target -Force}
|
||||
}
|
||||
$networkConfiguration=[IO.File]::ReadAllText((Join-Path $destination 'ced-network.json'))|ConvertFrom-Json
|
||||
$primaryDomainController=[string]$networkConfiguration.PrimaryController
|
||||
& (Join-Path $destination 'Set-SguCedClientNetwork.ps1')|Out-Null
|
||||
$source=Join-Path $PSScriptRoot 'Repair-SguCedWifi.ps1'
|
||||
$helper=Join-Path $destination 'Repair-SguCedWifi.ps1'
|
||||
if($source -ine $helper -and (-not(Test-Path -LiteralPath $helper) -or (Get-FileHash -LiteralPath $source).Hash -ne (Get-FileHash -LiteralPath $helper).Hash)){Copy-Item -LiteralPath $source -Destination $helper -Force}
|
||||
@@ -44,22 +52,24 @@ $profileState=& $helper
|
||||
if(-not $profileState.MachineProfileReady){
|
||||
# Computer authentication reads the existing restricted AD WLAN object.
|
||||
# The PSK stays in memory and Windows encrypts it into its machine store.
|
||||
$searchRoot=$null;$searcher=$null
|
||||
$searchRoot=$null;$searcher=$null;$found=$null
|
||||
try{
|
||||
# Serverless LDAP can select Azure's private DC address, which these clients
|
||||
# cannot route to. Use the local DC with signed and sealed machine binding.
|
||||
# The managed hosts entry directs this FQDN to the Azure public endpoint of
|
||||
# the primary DC; the signed and sealed machine binding protects the read.
|
||||
$domainDn=($computer.Domain.Split('.')|ForEach-Object{'DC='+$_}) -join ','
|
||||
$searchRoot=[DirectoryServices.DirectoryEntry]::new('LDAP://192.168.54.211/CN=Policies,CN=System,'+$domainDn)
|
||||
$searchRoot.AuthenticationType=[DirectoryServices.AuthenticationTypes]::Secure -bor [DirectoryServices.AuthenticationTypes]::Signing -bor [DirectoryServices.AuthenticationTypes]::Sealing
|
||||
$authentication=[DirectoryServices.AuthenticationTypes]::Secure -bor [DirectoryServices.AuthenticationTypes]::Signing -bor [DirectoryServices.AuthenticationTypes]::Sealing
|
||||
$searchRoot=[DirectoryServices.DirectoryEntry]::new("LDAP://$primaryDomainController/CN=Policies,CN=System,"+$domainDn,$null,$null,$authentication)
|
||||
$searcher=[DirectoryServices.DirectorySearcher]::new($searchRoot)
|
||||
$searcher.ClientTimeout=[TimeSpan]::FromSeconds(10)
|
||||
$searcher.ServerTimeLimit=[TimeSpan]::FromSeconds(10)
|
||||
$searcher.Filter='(&(objectClass=ms-net-ieee-80211-GroupPolicy)(cn=CED Wi-Fi))'
|
||||
[void]$searcher.PropertiesToLoad.Add('ms-net-ieee-80211-GP-PolicyData')
|
||||
$found=@($searcher.FindAll())
|
||||
$found=$searcher.FindAll()
|
||||
if($found.Count -ne 1){throw 'Expected exactly one authorized CED WLAN policy.'}
|
||||
[xml]$policy=[string]$found[0].Properties['ms-net-ieee-80211-gp-policydata'][0]
|
||||
$profile=$policy.SelectSingleNode('//*[local-name()="WLANProfile"]')
|
||||
$profileState=& $helper -ProvisionXml $profile.OuterXml
|
||||
}finally{if($searcher){$searcher.Dispose()};if($searchRoot){$searchRoot.Dispose()};$profile=$null;$policy=$null}
|
||||
}finally{if($found){$found.Dispose()};if($searcher){$searcher.Dispose()};if($searchRoot){$searchRoot.psbase.Dispose()};$profile=$null;$policy=$null}
|
||||
}
|
||||
if(-not $profileState.MachineProfileReady){throw 'Machine Wi-Fi profile is not ready.'}
|
||||
Start-ScheduledTask -TaskName $taskName
|
||||
$profileState
|
||||
Reference in new issue
Block a user