The issue I'm having is that it (appears) I can only mock the output of the call, but what I need to do is mock the INPUT. Meaning, I want to mock the Win32_OperatingSystem Class of a Windows 7 system, a Windows 8.1 system AND a Windows 10 system and execute the WMI Query against each mock to see how it behaves. I know I can do this by connecting to LIVE systems, but I'm hoping I can avoid that so I don't need to find or build a live system each time I want to test this.
I don't think what you are asking is possible. From my understanding, you're wanting to query a WMI repository without actually touching one. There's no way to mock what that WMI repo would return. You can only mock what a command returns. I suggest you collect a bunch of workstations and perform the actual query with PowerShell. If you do the actual query, you can then use Pester to validate those machines are returning what you'd expect.
The topic ‘Use Pester to Mock "Dummy Computers" for testing Get-WMIObject Queries’ is closed to new replies.