Reputation: 81
I understand what the following command is doing, but what is the purpose of the '[wmi]'?
gwmi Win32_USBControllerDevice |
% {[wmi]($_.Dependent)} |
Sort Manufacturer, Description,DeviceID |
ft Manufacturer, Description,DeviceID
Upvotes: 1
Views: 648
Reputation: 23395
The correct command is:
gwmi Win32_USBControllerDevice | %{[wmi]($_.Dependent)} | Sort Manufacturer, Description,DeviceID | ft Manufacturer, Description,DeviceID
This looks to have been taken from the example on this page: https://msdn.microsoft.com/en-us/library/aa394505(v=vs.85).aspx but has been copied incompletely.
The %
command is an alias for ForEach-Object.
[wmi]
is casting the Dependent
property of each object returned from Get-WMIObject as a WMI object.
It then sorts and outputs as a table.
To learn more about what the [wmi] part does, see this blog post: https://mcpmag.com/articles/2013/07/23/object-spell-in-powershell.aspx
Upvotes: 1