Using PowerCLI with PowerShell for running scripts on a vCenter

on

First, we need to disable a few security settings. Start the process by running PowerShell on Admin mode. Run each snippet on the console.

 

We need to enable TLS 1.2 on PowerShell:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

 

Set the execution policy to run scripts:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

 

Install the PowerCli module, creating a destination folder for it first:

Save-Module -Name VMware.PowerCLI -Path C:\CLI

Install PowerCLI – the AllowClobber switch will overwrite any pending/broken installs you may have done before

Install-Module -Name VMware.PowerCLI -AllowClobber

Import the VimAutomation Module:

Import-Module VMware.VimAutomation.Core

 

Ok, we are ready to connect to our vCenter!

connect-viserver IP_OR_FQDN

 

If your vCenter doesn’t have a proper certificate (i.e. you are connecting via IP), you will need to disable the certificate checkup:

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false

 

Leave a Reply

Your email address will not be published. Required fields are marked *