错误网络适配器配置Win 32

时间:2019-04-05 08:40:57

标签: powershell scripting

我想编写从主机名获取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

0 个答案:

没有答案