VMware Cloud Community
crosen
Contributor
Contributor

WARNING: Unable to populate snapshot size due to unsiffucient

I moved my scripts to a new server and am getting this error from one of the vCenters (but not on the original server)...

function vCell01SnapshotSize {

    $VIServer = "rtpvcell70"

    connect-viserver -server $VIServer -user $User -password $Password

    $filenamesnaps = 'C:\MyDocs\work\Virtualization\VMWare\VMware_Healthcheck\Notes_Fields\TCOMDB_Data\vcell01_consolidated_snapshotsize.csv'

$DiskInfoDef = @"

public struct DiskInfo {

    public string VMname;

    public string TotalSnapMB;   

"@

    $vms = Get-View -ViewType VirtualMachine -Property "LayoutEx", "Snapshot", "Config.Hardware.Device", "Name"

    $maxSnapshot = ($vms | %{$_.LayoutEx.Snapshot.Count} | Measure-Object -Maximum).Maximum

    1..$maxSnapshot | %{

        $DiskInfoDef += ("`n`tpublic string Snap" + $_ + "MB;")

    }

    $DiskInfoDef += "`n}"

    Add-Type -Language CsharpVersion3 -TypeDefinition $DiskInfoDef

    $snapHash = @{}

    filter Get-SnapHash{

        $snapHash[$_.Snapshot.Value] = $_.Name

        if($_.ChildSnapshotList){

            $_.ChildSnapShotList | Get-SnapHash

        }

    }

    $vms | %{

        $vm = $_

        if($vm.Snapshot){

            $vm.Snapshot.RootSnapshotList | Get-SnapHash

        }

        $_.Config.Hardware.Device | where {$_.DeviceInfo.Label -like "Hard disk *"} | %{

            $hd = $_

            $vm.LayoutEx.Disk | where {$_.Key -eq $hd.Key} | %{

                $diskFiles = $_.Chain | %{$_.FileKey} | %{$_}

            }

            $diskInfo = New-Object DiskInfo

            $diskInfo.VMname = $vm.Name

            $snapNr = 1

            if($vm.Snapshot){

                $totalSnapMB = 0

                $vm.LayoutEx.Snapshot | %{

                    $_.Disk | where {$_.Key -eq $hd.Key} | %{

                        $prevFiles = $_.Chain | %{$_.FileKey} | %{$_}

                    }

                    $vm.LayoutEx.Disk | where {$_.Key -eq $hd.Key} | %{

                        foreach($chain in $_.Chain){

                            if($prevFiles -notcontains $chain.FileKey[0] -and $prevFiles -notcontains $chain.FileKey[1]){

                                break

                            }

                        }

                    }

                    $snapFiles = $chain.FileKey | %{$_}

                    $snapSize = ""

                    if($snapFiles){

                        $snapAllocated = 0

                        $vm.LayoutEx.File | where {$snapFiles -contains $_.Key} | %{

                            $snapAllocated += $_.Size

                        }

                        $snapSize = ("{0:N1}" -f ($snapAllocated / 1MB))

                    }

                    $diskInfo.("Snap" + $snapNr + "MB") = $snapSize

                    $totalSnapMB += ($snapAllocated / 1MB)

                    $snapNr++

                }

                $totalSnapMB = ($totalSnapMB/1024)

                $diskInfo.TotalSnapMB = ("{0:N1}" -f $totalSnapMB)

            }

            $diskInfo

        }

    } | Export-Csv $filenamesnaps -UseCulture -NoTypeInformation

    Disconnect-VIServer -Confirm:$False

}

function vCell01SnapshotQty {

    $VIServer = "rtpvcell70"

    connect-viserver -server $VIServer -user $User -password $Password

    $filenamesnapqty = 'C:\MyDocs\work\Virtualization\VMWare\VMware_Healthcheck\Notes_Fields\TCOMDB_Data\vcell01_consolidated_snapshotqty.csv'

    Get-VM | select Name,

        @{N="#Snapshots";E={($_ | Get-Snapshot).Count}}    |`

        Export-Csv $filenamesnapqty -NoTypeInformation -UseCulture

    Disconnect-VIServer -Confirm:$False

}

0 Kudos
6 Replies
LucD
Leadership
Leadership

Would you mind giving us the complete error message ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
crosen
Contributor
Contributor

That is all it gives over and over...

WARNING: Unable to populate snapshot size due to unsiffucient permissions.
WARNING: Unable to populate snapshot size due to unsiffucient permissions.
WARNING: Unable to populate snapshot size due to unsiffucient permissions.
WARNING: Unable to populate snapshot size due to unsiffucient permissions.
WARNING: Unable to populate snapshot size due to unsiffucient permissions.
WARNING: Unable to populate snapshot size due to unsiffucient permissions.
WARNING: Unable to populate snapshot size due to unsiffucient permissions.
WARNING: Unable to populate snapshot size due to unsiffucient permissions.
WARNING: Unable to populate snapshot size due to unsiffucient permissions.

0 Kudos
LucD
Leadership
Leadership

Ok, the "permissions" part seems to indicate that the account you used to connect doesn't have the required privileges to fetch that info for a snapshot. What role does your account have ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
crosen
Contributor
Contributor

It is an administrator account and the same script that has the same credentials hard-coded works on the original server.

0 Kudos
LucD
Leadership
Leadership

Are you sure that the copy of your script is correct ?

I see 2 functions that are apparently never called, and there seems to be an unmatched closing curly brace.

Perhaps it is easier to attach your script as an attachment ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
LucD
Leadership
Leadership

I'm still suspecting that the account you connect with is missing a privilege.

I quote from the Get-SNapshot cmdlet help:

The disk size of the snapshots is retrieved only if you have the  "Datastore/Browse datastore" privilege to the datastore where the  shapshot is located. Otherwise, the following message is displayed:  "Unable to populate snapshot size due to unsiffucient permissions."


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos