Configure CED Wi-Fi policy and scoped management enrollment
This commit is contained in:
1 parent
b07dbe17d0
commit
46c0be732a
14 files changed
+921
-6
No files matched your search
@@ -0,0 +1,55 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory)][PSCredential]$Credential,
|
||||
[string]$TargetOuDn = 'OU=Centro de Experiencia Digital,OU=Laboratorio,DC=lci,DC=lasalle,DC=mx',
|
||||
[string]$Ssid = 'Centro de Experiencia Digital',
|
||||
[string]$WacThumbprint = 'CF2B7C6899885BF9EB0E59054F8E8AB2D4390513'
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Import-Module ActiveDirectory
|
||||
Clear-DnsClientCache
|
||||
$computers = @(Get-ADComputer -SearchBase $TargetOuDn -Filter 'Enabled -eq $true' -Properties DNSHostName)
|
||||
$online = @()
|
||||
foreach ($computer in $computers) {
|
||||
$client = [Net.Sockets.TcpClient]::new()
|
||||
try {
|
||||
$connect = $client.BeginConnect($computer.DNSHostName,5985,$null,$null)
|
||||
$available = $connect.AsyncWaitHandle.WaitOne(1000) -and $client.Connected
|
||||
} catch { $available = $false } finally { $client.Dispose() }
|
||||
if ($available) { $online += $computer.DNSHostName }
|
||||
else { [pscustomobject]@{Name=$computer.Name;Reachable=$false;WifiConnected=$false;ClientRunning=$false;Error='No WinRM TCP connection at current DNS address.'} }
|
||||
}
|
||||
$options = New-PSSessionOption -OpenTimeout 10000 -OperationTimeout 60000
|
||||
if ($online.Count) {
|
||||
$reported = @(Invoke-Command -ComputerName $online -Credential $Credential -Authentication Kerberos -SessionOption $options -ErrorAction Continue -ArgumentList $Ssid,$WacThumbprint -ScriptBlock {
|
||||
param($ssid,$thumbprint)
|
||||
$liveSsid = @([Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentType=WindowsRuntime]::GetConnectionProfiles() | Where-Object IsWlanConnectionProfile | ForEach-Object { $_.WlanConnectionProfileDetails.GetConnectedSsid() })
|
||||
$event = Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-WLAN-AutoConfig/Operational';Id=8001} -MaxEvents 1 -ErrorAction SilentlyContinue
|
||||
$profile = $null; $authentication = $null
|
||||
if ($event) {
|
||||
[xml]$xml = $event.ToXml()
|
||||
$profile = ($xml.Event.EventData.Data | Where-Object Name -eq ProfileName).'#text'
|
||||
$authentication = ($xml.Event.EventData.Data | Where-Object Name -eq AuthenticationAlgorithm).'#text'
|
||||
}
|
||||
$service = Get-Service CcmExec -ErrorAction SilentlyContinue
|
||||
$version = $null; $site = $null
|
||||
if ($service.Status -eq 'Running') {
|
||||
$sms = Get-CimInstance -Namespace root\ccm -ClassName SMS_Client -ErrorAction SilentlyContinue
|
||||
$version = $sms.ClientVersion
|
||||
$site = (Invoke-CimMethod -Namespace root\ccm -ClassName SMS_Client -MethodName GetAssignedSite -ErrorAction SilentlyContinue).sSiteCode
|
||||
}
|
||||
[pscustomobject]@{
|
||||
Name=$env:COMPUTERNAME;Reachable=$true;SSID=$liveSsid -join ',';Profile=$profile
|
||||
WifiConnected=($liveSsid -contains $ssid -and $profile -eq $ssid)
|
||||
IP=@(Get-NetIPAddress -AddressFamily IPv4 | Where-Object IPAddress -like '192.168.*' | ForEach-Object IPAddress) -join ','
|
||||
Authentication=$authentication;ClientRunning=($service.Status -eq 'Running');ClientVersion=$version;Site=$site
|
||||
WacRootTrusted=(Test-Path ("Cert:\LocalMachine\Root\"+$thumbprint));Error=$null
|
||||
}
|
||||
})
|
||||
$reported
|
||||
foreach ($hostname in $online) {
|
||||
if ($reported.PSComputerName -inotcontains $hostname) {
|
||||
[pscustomobject]@{Name=$hostname.Split('.')[0];Reachable=$false;WifiConnected=$false;ClientRunning=$false;Error='WinRM session or client verification failed after TCP probe.'}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user