This question is about an odd interaction between PowerCLI and PowerShell.
I hope someone can shed some light on this as I can't find a similar question elsewhere.
I recently accidentally typed the powershell command "get-vmswitch" into my PowerCLI window. Every Get-* command I typed after that retrieved information from the locally installed Hyper-V instead of the vCenter server I had been connected to.
I can repeat the behavior every time.
Open PowerCLI on my 2012 R2 laptop
connect-VIServer 192.168.0.16
get-VM displays the VMs managed by my vCenter server
get-VM -server 192.168.0.16 #also works
get-vmswitch #displays the network adapters on my 2012R2 laptop
get-vm #displays the Hyper-V VMs on my laptop
get-vm -server 192.168.0.16 # throws an error no parameter matches server
$displayviserver #displays the expected vCenter IP address
connect-viserver #appears to work, but all commands still act against the local machine
I tried a few other commands. All acted against the local Hyper-V instead of against vCenter. I have not researched the command overlap to ensure that all the commands I was trying aren't just PS commands that P-CLI uses in a different context, which I somehow broke. I'd love to understand that context though. Especially if I could learn to access Power-CLI commands in a regular PowerShell window.
My lab is a collection of laptops running Hyper-V and ESXi.
I know that get-vmswitch is a PowerShell command for Hyper-V, but how does it subvert my PowerCLI session?
Is there a way to recover the session other than closing powerCLI and re-opening it?
--thanks to all for your insight.