So let's get straight into it,
and we'll talk about using the Invoke‑Command for querying.
So the Invoke‑Command executes commands on local and remote computers.
It returns all output from the commands,
including any errors,
and it also supports executing what's called a script block as a command,
a script block being some other piece of PowerShell
code that we need to execute.
So what does this look like?
Well, if I want to retrieve running services locally,
I can simply say Invoke‑Command, and there we see the ScriptBlock property,
which is in the squirrely brackets, which we're using Get‑Service.
So that will simply return all of the services.
If I extend this a little bit, I can use the similar syntax we used before,
which was Get‑Service with a Where‑Object to get only the running options.
If I wanted to run the same on a remote server,
I can simply add ‑ComputerName WIN10, and then either of those options
would work when trying to run it against a remote machine.