Hello,
I'm using this to how snapshots and their sizes.
Connect-VIServer -Server vc.domain.com -Credential $credentials
get-vm | get-snapshot | select vm, name, description, created, sizegb | Format-Table -Property vm,name,description,created,sizegb
This one shows as having a 2TB snapshot!
In vCenter it shows as 80GB
As my script wrong?
See this script : https://powershell.ro/generate-detailed-snapshots-report-using-powercli-scripting/
I`m using this part to get the snapshot:
Get-VM | Sort | Get-Snapshot | Select-Object @{n="VCenter"; e={$VCenter}}, VM, @{n="SnapshotState"; e={$_.PowerState}}, Name, Description, @{Name="SizeGB";Expression={ [math]::Round($_.SizeGB,2) }}, Created, @{Name="DaysOld";Expression={(New-TimeSpan -End (Get-Date) -Start $_.Created).Days }}
The Get-Snapshot cmdlet and the Web Client are both showing correct values, the difference is that they are measuring different things.
One is returning the size of the files (mostly the VMDK) before the snapshot (PowerCLI) and the other is returning the size of the delta disks (and some other snapshot-related files) created during/after the snapshot.
Have a look at my yadr – A vdisk reporter post.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm only interested in the snapshot delta size I guess as this is the real size maybe.
I tried your link too and the script there, but it fails on all the labels. It mentions about >NET 3.5 which is installed and WOW64 which I'm not sure about. Do you think it's related?
PS C:\Windows\system32> C:\Scripts\VMware\Snapshotsplus.ps1
Name Port User
---- ---- ----
vc.domain.com 443 VSPHERE.LOCAL\logs
Add-Type : Cannot add type due to the following exception: Compiler executable file csc.exe cannot be found.. Verify that Microsoft .NET Framework 3.5 is installed. On x64-based versions of Windows, you must
also install the WOW64 feature.
At C:\Scripts\VMware\Snapshotsplus.ps1:27 char:1
+ Add-Type -Language CsharpVersion3 -TypeDefinition $DiskInfoDef
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Type], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.AddTypeCommand
New-Object : Cannot find type [DiskInfo]: verify that the assembly containing this type is loaded.
At C:\Scripts\VMware\Snapshotsplus.ps1:63 char:15
+ $diskInfo = New-Object DiskInfo
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
The property 'VMname' cannot be found on this object. Verify that the property exists and can be set.
At C:\Scripts\VMware\Snapshotsplus.ps1:64 char:3
+ $diskInfo.VMname = $vm.Name
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
The property 'Label' cannot be found on this object. Verify that the property exists and can be set.
At C:\Scripts\VMware\Snapshotsplus.ps1:65 char:3
Another example of my script I originally posted at the top is this one below. In vCenter it is showing it has a 4.06TB snapshot, but my report shows it as 64.8GB. It's as if it's just looking at the main .vmdk
Is there anyway to change/update my script to show the same as vCenter?
Thanks
The impression that is looking only at the main VMDK is because that is probably the biggest file.
You should see that it not the main VMDK when you have multiple snapshots and you look at the latest snapshot.
Are you running the script with PSv5.1 or PSv7.*?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm using:
PSVersion 5.1.17763.3770
VMware.PowerCLI 12.5.0 build 19195797
So it seems PS sees the biggest file whereas vCenter somehow uses the smaller delta
No, that is not what I said.
Check with a VM with 2 fresh snapshots.
Is .NET enabled in the Windows features?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I tested the yadr – A vdisk reporter, it is working for me, the Snap1MB size still different from vSphere. I need some more research to figure out.
BTW, I am running the yadr – A vdisk reporter with PowerShell 5.1.19041.3031 and PowerCLI 12.7.0 build 20091289
PS C:\docs\scripts> $PSversionTable
Name Value
---- -----
PSVersion 5.1.19041.3031
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.3031
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\docs\scripts> get-powercliversion
PowerCLI Version
----------------
VMware.PowerCLI 12.7.0 build 20091289
---------------
Component Versions
---------------
VMware Common PowerCLI Component 12.7 build 20067789
VMware Cis Core PowerCLI Component PowerCLI Component 12.6 build 19601368
VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 12.7 build 20091293
Check with my script with a VM and 2 snapshots or the one in your link?
Looks like 3.5 won't install on this WIn2029 server for some reason.
then
What a pain, I'll look into this part. I'll try this:
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:X:\sources\sxs
That is a known issue when trying to install .NET 3.5.
Search for .NET 3.5 and 0x800f0954
You can try one of the methods in How to enable .NET Framework 3.5 on Windows Server 2019, 2022 - GreenCloud Documentation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks I got that installed and the script runs!
This is what I see for that server:
But in venter it's saying 80G
What is right and what is wrong?
Both are correct, they just measure different things (see my earlier reply)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
So based on that screenshot is vCenter just returning the size of the main vmdk before a snapshot, but shows in vCenter as that snapshot size?
Apologies I'm not grasping this.