|
|
@ -44,9 +44,9 @@ Function Get-MachineSid {
|
|
|
|
|
|
|
|
|
|
|
|
$cim_instances = @{}
|
|
|
|
$cim_instances = @{}
|
|
|
|
|
|
|
|
|
|
|
|
Function Get-LazyCimInstance([string]$instance_name) {
|
|
|
|
Function Get-LazyCimInstance([string]$instance_name, [string]$namespace="Root\CIMV2") {
|
|
|
|
if(-not $cim_instances.ContainsKey($instance_name)) {
|
|
|
|
if(-not $cim_instances.ContainsKey($instance_name)) {
|
|
|
|
$cim_instances[$instance_name] = $(Get-CimInstance $instance_name)
|
|
|
|
$cim_instances[$instance_name] = $(Get-CimInstance -Namespace $namespace -ClassName $instance_name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $cim_instances[$instance_name]
|
|
|
|
return $cim_instances[$instance_name]
|
|
|
@ -229,15 +229,26 @@ if($gather_subset.Contains('facter')) {
|
|
|
|
|
|
|
|
|
|
|
|
if($gather_subset.Contains('interfaces')) {
|
|
|
|
if($gather_subset.Contains('interfaces')) {
|
|
|
|
$netcfg = Get-LazyCimInstance Win32_NetworkAdapterConfiguration
|
|
|
|
$netcfg = Get-LazyCimInstance Win32_NetworkAdapterConfiguration
|
|
|
|
|
|
|
|
|
|
|
|
$ActiveNetcfg = @()
|
|
|
|
$ActiveNetcfg = @()
|
|
|
|
$ActiveNetcfg += $netcfg | where {$_.ipaddress -ne $null}
|
|
|
|
$ActiveNetcfg += $netcfg | where {$_.ipaddress -ne $null}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$namespaces = Get-LazyCimInstance __Namespace -namespace root
|
|
|
|
|
|
|
|
if ($namespaces | Where-Object { $_.Name -eq "StandardCimv" }) {
|
|
|
|
|
|
|
|
$net_adapters = Get-LazyCimInstance MSFT_NetAdapter -namespace Root\StandardCimv2
|
|
|
|
|
|
|
|
$guid_key = "InterfaceGUID"
|
|
|
|
|
|
|
|
$name_key = "Name"
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$net_adapters = Get-LazyCimInstance Win32_NetworkAdapter
|
|
|
|
|
|
|
|
$guid_key = "GUID"
|
|
|
|
|
|
|
|
$name_key = "NetConnectionID"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$formattednetcfg = @()
|
|
|
|
$formattednetcfg = @()
|
|
|
|
foreach ($adapter in $ActiveNetcfg)
|
|
|
|
foreach ($adapter in $ActiveNetcfg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$thisadapter = @{
|
|
|
|
$thisadapter = @{
|
|
|
|
default_gateway = $null
|
|
|
|
default_gateway = $null
|
|
|
|
|
|
|
|
connection_name = $null
|
|
|
|
dns_domain = $adapter.dnsdomain
|
|
|
|
dns_domain = $adapter.dnsdomain
|
|
|
|
interface_index = $adapter.InterfaceIndex
|
|
|
|
interface_index = $adapter.InterfaceIndex
|
|
|
|
interface_name = $adapter.description
|
|
|
|
interface_name = $adapter.description
|
|
|
@ -248,6 +259,10 @@ if($gather_subset.Contains('interfaces')) {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$thisadapter.default_gateway = $adapter.DefaultIPGateway[0].ToString()
|
|
|
|
$thisadapter.default_gateway = $adapter.DefaultIPGateway[0].ToString()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$net_adapter = $net_adapters | Where-Object { $_.$guid_key -eq $adapter.SettingID }
|
|
|
|
|
|
|
|
if ($net_adapter) {
|
|
|
|
|
|
|
|
$thisadapter.connection_name = $net_adapter.$name_key
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$formattednetcfg += $thisadapter
|
|
|
|
$formattednetcfg += $thisadapter
|
|
|
|
}
|
|
|
|
}
|
|
|
|