I'm stuck a bit on a script I am working on and hopefully this is possible.
I am doing a get-wmiobject and one of the things I am doing is any time an Edge server is checked, I do a get-credential since it's a workgroup machine. Because of that, I am wanting to do an if ($server.isEdgeServer -eq $true) { -Credential get-Credential }.
But I can't figure out how to do something like get-wmiobject Computer $server -class classhere ifstatementhere. This way if it's not an Edge Server the command will run without the ifstatement conflicting with the get-wmiobjectcommand but if it's an Edge server, the ifstatement will run but it'll use -Credential Get-Credential.
Is there a way to do what I am looking for?