我想编写从主机名获取mac地址的脚本,但是当我使用Win32_NetworkAdapterConfiguration时出现错误
操作系统Windows 10,但我需要脚本也可以在Windows 7上运行
Get-MACAddress -strComputer hostname
function Get-MACAddress {
param ($strComputer)
$colItems = get-wmiobject -class "Win32_NetworkAdapterConfiguration" -computername $strComputer |Where{$_.IpEnabled -Match "True"}
foreach ($objItem in $colItems) {
$objItem |select Description,MACAddress
}
}
$ colItems = get-wmiobject -class“ Win32_NetworkAdapterConfiguration” ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~ + CategoryInfo:未指定:(:) [Get-WmiObject],UnauthorizedAccessException + FullyQualifiedErrorId:System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand