2015-05-19 56 views
0

我执行了一个命令,并且使用了“fl”格式列表。输出是“fl”不被识别为内部或外部命令。我也遇到了与“Get-WmiObject”相同的问题。随意评论任何其他信息。格式列表无法在PowerShell中识别

C:\Windows\system32>powershell.exe -Command Get-WmiObject -query "select * from msiscsi_nicconfig where Instancename LIKE '%ROOT\\ISCSIPRT\\0000_0%'" -namespace "root/wmi" | fl MacAddress 

输出:

'fl' is not recognized as an internal or external command, 
operable program or batch file. 

回答

0

我认为你正试图从cmd从命令行运行的PowerShell。您的PowerShell命令以"root/wmi"结尾。管道| fl MacAddresscmd解释,而不是由Powershell解释。

您应该在Powershell中运行整个命令。

1

管道和fl正在由DOS解释,而不是Powershell,并且由于fl不是DOS命令,您正在收到错误。你需要做这样的事情:

powershell.exe -Command " & {Get-WmiObject -query "select * from msiscsi_nicconfig where Instancename LIKE '%ROOT\\ISCSIPRT\\0000_0%'" -namespace "root/wmi" | fl MacAddress}"

Run PowerShell command (with pipeline) in CMD

+0

当我执行上面的命令我得到输出“拒绝访问” @Tony – sam

+0

你搜索“否认获得-WmiObject可以访问“?这就是我会做的。这是一个完全独立的问题。 –

+0

我刚刚执行了你指定的命令,输出是“拒绝访问” – sam