I just upgrade my PowerCLI to 6.3 from PowerCLI 5.8 I tried the following code to load the modules but it doesn't seem to work. Any input would be nice. Thanks!
if (!([Security.Principal.WindowsPrincipal][System.Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([System.Security.Principal.WindowsBuiltInRole] "Administrator")) {
[void][System.Windows.Forms.MessageBox]::Show("This application must be ran using an account with Admin rights.")
exit
} else { $erroractionpreference = "SilentlyContinue"
# PowerCLI 6.5 uses posh modules exclusively. Check if modules are available and if not load snapin for ver 5.8 or earlier...if installed at all.
$PCliModule = Get-Module -ListAvailable vmware.vimautomation.core
if ($PCliModule -ne $null) {
Import-Module vmware.vimautomation.core -ea SilentlyContinue -wa SilentlyContinue
# add result to var so can log it once up and running.
$script:PCLIver = Get-PowerCLIVersion
} else {
$Snapin = "vmware.vimautomation.core"
if (Add-Snapin -Snapin $Snapin) {
set-PowerCLIConfiguration -InvalidCertificateAction "Ignore" -Confirm:$false
$script:PCLIver = Get-PowerCLIVersion
} else {
[void][System.Windows.Forms.MessageBox]::Show("This application requires $Snapin to be installed.?")
exit
}