Search code examples
powershellvmwarepowercli

PowerCLI Connect-VIServer permission denied after upgrade


Cross posted from the VMware communities page.

I have been running PowerCLI 6.0 Release 2 with no issues. I upgraded to PowerCLI 6.1 Release 1 on Friday and now I cannot connect to my host. Nothing has changed on the host side. If I use my other workstation which I did not upgrade, I can connect without issue.

Some sample code (this gets hard drive use and returns a CSV of the details):

Import-Module VMware.VimAutomation.Core

$VmHostName = "physical_host"
$VmGuestName = "vm_host"
$VmGuestUser = "Administrator"
$VmGuestPassword = (ConvertTo-SecureString -String "mypassword" -AsPlainText -Force)

Connect-VIServer -Server $VmHostName -Credential $(Get-Credential)

$GuestCommand = @"
Get-PSDrive -Name $($Drive -join ',') -PSProvider FileSystem | Select-Object Name,Used,Free | ConvertTo-Csv -NoTypeInformation
"@

$Output = Invoke-VMScript -VM $VmGuestName -GuestUser $VmGuestUser -GuestPassword $VmGuestPassword -ScriptText $GuestCommand | ConvertFrom-Csv

The error I receive is:

Connect-VIServer : Permission to perform this operation was denied.
At line:1 char:1
+ Connect-VIServer -Server $VmHostName -Credential $(Get-Credential ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Connect-VIServer], VimException
    + FullyQualifiedErrorId : VMware.Vim.VimException,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer

Has something changed in PowerCLI? Do I need to be added to a permission group on the host or something? I'm not on the infrastructure team, so I will need to request specific access.

Thanks in advance.


Solution

  • Many users posted in my thread on the VMWare forums stating the same issue. It appears to have been a bug in PowerCLI. I am now using version 6.5.0.2604913 and this is no longer an issue.