SCCM: Preflight tasksequence

By:

The query thats checks if all network adapters and their connected-state

$A = Foreach ($row in (Get-WmiObject -Namespace "root/WMI" -Query "SELECT * FROM MSNdis_PhysicalMediumType"))
{
    [pscustomobject]@{
        Name = $row.InstanceName
        NDIS     = $row.NdisPhysicalMediumType
        ACT    = (get-wmiobject -Namespace "root/cimv2" -Query "Select * from win32_networkadapter") | Where-Object {$_.Name -eq $row.InstanceName} | Select-Object -ExpandProperty NetEnabled
    }
}

($A | Where-Object {$_.NDIS -eq 0 -and $_.ACT -eq $true}) -ne $null

$A gives a object with all adapters, their type and connected-state.

NDIS gives the type. I Found 0 = wired, 9= WIFI and 10 = bluetooth so far.

To put that into a ‘run commandline’ step in SCCM

powershell -executionpolicy bypass -command "$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment;$a=Foreach ($row in (Get-WmiObject -Namespace 'root/WMI' -Query 'SELECT * FROM MSNdis_PhysicalMediumType')){[pscustomobject]@{Name = $row.InstanceName;NDIS=$row.NdisPhysicalMediumType;ACT=(get-wmiobject -Namespace 'root/cimv2' -Query 'Select * from win32_networkadapter') | Where-Object {$_.Name -eq $row.InstanceName} | Select-Object -ExpandProperty NetEnabled}};$tsenv.Value('OSD_TS_CableConnected')=($a | Where-Object {$_.NDIS -eq 0 -and $_.ACT -eq $true}) -ne $null"

The Tasksequencevariable OSD_TS_CableConnected now contains a True or False


Geef een reactie

Je e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *

Deze site gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie-gegevens worden verwerkt.