Prerequisites:
PS C:\> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 19041 546
PS C:\> Get-Module -Name VMware.PowerCLI -ListAvailable
Directory: C:\Users\TestUser\Documents\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 12.0.0.... VMware.PowerCLI
The steps below need to be performed from a Windows system. You can skip Step 1 & Step 2 if you have already done so before.
Step 1:
- Install VMware PowerCLI in Windows PowerShell.
- To uninstall old version of VMware PowerCLI, run:
PS C:\> (Get-Module -Name VMware.PowerCLI -ListAvailable).RequiredModules | Uninstall-Module -Force
PS C:\> Get-Module -Name VMware.PowerCLI -ListAvailable | Uninstall-Module -Force
- To install the latest VMware PowerCLI from PowerShell repository 'PSGallery', run:
PS C:\> Install-Module -Name VMware.PowerCLI -Scope CurrentUser
This installs VMware PowerCLI to the current user directory $home\Documents\PowerShell\Modules.
Note, you don't need to run the script in a PowerShell (Admin) session.
Step 2:
- Set Windows PowerShell execution policy:
PS C:\> Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
- Close the current Windows PowerShell window, re-start Windows PowerShell.
Step 3:
Save this script to a local file, e.g.,
'C:\Tool\Configure-GuestStore.ps1'.
Step 4:
Run this command to set Prompt if the server certificate is not trusted:
Set-PowerCLIConfiguration -Scope Session -InvalidCertificateAction Prompt
Command Samples:
Sample test commands (Enter empty string to clear repository URL setting and disable GuestStore)
Configure-GuestStore.ps1 -Server '<VC server name>' -User '[email protected]' -Password '********' \ -Datacenter '<datacenter name>' -ConfigAction getConfigure-GuestStore.ps1 -Server '<VC server name>' -User '[email protected]' -Password '********' \ -Datacenter '<datacenter name>' -ConfigAction set -Url 'ds:///vmfs/volumes/5bda46e0-08260d5c-3328d0946644b1a3/GuestStore'Configure-GuestStore.ps1 -Server '<VC server name>' -User '[email protected]' -Password '********' \ -Datacenter '<datacenter name>' -ConfigAction set -Url ''Configure-GuestStore.ps1 -Server '<VC server name>' -User '[email protected]' -Password '********' \ -Cluster '<cluster name>' -ConfigAction get