Powershell Authentication Help Post Server 2012 R2 Upgrade

Hello,

We've recently upgraded our VMWare vCenter server from 2008 R2 to 2012 R2 and upgraded vCenter from 5.0.0 to 5.5.0.  Since then our SAM PS script that checks for snapshots (below) is failing with permissions.

Add-PSSnapin -Name VMware.VimAutomation.Core

#If you get an out of memory error on the vCenter Server run "set-item wsman:localhost\Shell\MaxMemoryPerShellMB 768"

function Get-Snaps{

    $vms = get-vm | where {$_.Name -ne "SERVER1"} | sort name

    $vmsnaps = @()

    $i=0

    $Age = 7

    foreach($vm in $vms){

    $snap = Get-Snapshot $vm

    if($snap){

           $vmsnaps += $vm

     #write-host -fore green `n `t $vm

     $snapshots = Get-Snapshot $vm

     foreach ($snapshot in $snapshots){

               

                if ( $snapshot.Created -lt (Get-Date).AddDays( -$Age ) ) {

        $FSnapshots = $FSnapshots + "" + $vm + "</br>"

                    $i=$i+1

                }

               

            }

    }

    }

write-host "Message:"$FSnapshots

write-host "Statistic:"$i

}

Connect-VIServer ${ip} -WarningAction 0

Get-Snaps

Disconnect-VIServer -Force:$true -Confirm:$false

I've tried connecting on my vCenter server using the "Connect-VIServer <FQDN>" but its prompting for credentials which it didnt normally do, I guess it used integrated / pass through credentials.

Anyone any ideas how I can fix this?

Thanks,

Peter

  • You could try to change the following line:
    Connect-VIServer ${ip} -WarningAction 0

    To:

    Connect-VIServer -Credential ${CREDENTIAL} ${ip} -WarningAction 0


    In this case credentials may provide access to system with adequate permissions to connect.

    You may also want to try playing with –User and –Password arguments.