Can anyone here please assist me in resetting the global:DefaultVIServer and global:DefaultVIServers system variables into $null ?
because I cannot do anything with my PowerShell anymore even after reinstalling the PowerCLi and upgrading it into 5.1U2, here's the output of the version information and the configuration information:
Scope ProxyPolicy DefaultVIServerMode InvalidCertificateAction DisplayDeprecationWarnings WebOperationTimeoutSeconds
----- ----------- ------------------- ------------------------ -------------------------- --------------------------
Session UseSystemProxy Multiple Unset True 300
User UseSystemProxy Multiple
AllUsers Single
WARNING: Error initializing default drive: 'Unable to find a default server with Active Directory Web Services running.'.
PowerCLI Version
----------------
VMware vSphere PowerCLI 5.1 Release 2 build 1012425
---------------
Snapin Versions
---------------
VMWare AutoDeploy PowerCLI Component 5.1 build 768137
VMWare ImageBuilder PowerCLI Component 5.1 build 768137
VMware License PowerCLI Component 5.1 build 669840
VMware VDS PowerCLI Component 5.1 build 1012428
VMware vSphere PowerCLI Component 5.1 build 1012428
Due to this error, I cannot even issue a simple PowerCLi command to get the list of my VM, see the following error:
WARNING: Error initializing default drive: 'Unable to find a default server with Active Directory Web Services running.'.
Get-VM : You have modified the global:DefaultVIServer and global:DefaultVIServers system variables. This is not allowed. Please reset them to $null and reconnect to the vSphere server.
At C:\Users\Albert\AppData\Local\Temp\4a44b139-36b2-4045-bf3c-a51cff5472b4.ps1:1 char:7
+ Get-VM <<<<
+ CategoryInfo : NotSpecified: (:) [Get-VM], InvalidState
+ FullyQualifiedErrorId : VMware.VimAutomation.ViCore.Types.V1.ErrorHandling.InvalidState,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM
Any help would be greatly appreciated.
Thanks
Best Answer
I'm not exactly sure how you set those in the first place but you can remove the variables (rather than null them) using the following.
1) First check what you have with in a fresh PowerCLI session with Get-Variable (you should see something like this but likely a value for a server)
2) Remove each using Remove-Variable DefaultVIServer and Remove-Variable DefaultVIServers 3) Try connecting to the correct vCenter with Connect-VIServer yourvcenter.domain.com*
If you keep having variables reset, it's possible you've customized something in the startup file (C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1) so you might need to replace/remove the entries there (never tried that, just taking a guess)
PS. Sorry about formatting messs, still getting used to the format