sam
sam

Reputation: 83

format list is not recognised in powershell

I executed a command and in that i used "fl" format list. Output is "fl" is not recognised as internal or external command. I faced same issue with "Get-WmiObject " also. Feel free to comment for any other info.

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

Output:

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

Upvotes: 0

Views: 2251

Answers (2)

Tony Hinkle
Tony Hinkle

Reputation: 4742

The pipe and fl are being interpreted by DOS, not Powershell, and since fl is not a DOS command you are getting the error. You need to do something like this:

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

See Run PowerShell command (with pipeline) in CMD

Upvotes: 1

Duncan
Duncan

Reputation: 95682

I think you are trying to run powershell from cmd command line. Your powershell command ends with "root/wmi". The pipeline | fl MacAddress is interpreted by cmd not by Powershell.

You should run the entire command inside Powershell.

Upvotes: 0

Related Questions