Difference between Invoke-Command and query directly
问题 I'm currently working on a script that queries the disk information from a server. I'm stack with a problem and I really don't know whats going on here. May you can help me. The following code is working (ComputerName replaced): $space1 = Invoke-Command -ComputerName "xxxxxx" -ScriptBlock { Get-WmiObject -Class Win32_LogicalDisk -Filter "DeviceID='C:'" } This code works kinda well and may takes around 2 seconds to execute. After some experimenting I found a way how I can query it even faster.