I'm attempting to generate a report of all snapshots in the ESX environment.
1) Installed PowerShell 2.0 for Windows XP
2) Installed VMware PowerCLI 4.0 U1
3) Installed VMware VI Toolkit for Windows 1.5
4) Added PSSnapin VMware.VimAutomation.Core
5) Imported Module viToolkitExtensions.psm1 version 74794
6) Found community recommended command of "Get-VM | Get-TkeSnapshotExtended | select Name, VM, SizeMB"
This does work! However powershell returns to following error between each snapshot result:
Add-Member : Cannot add a member with the name "SizeMB" because a member with that name already exists. If you want to
overwrite the member anyway, use the Force parameter to overwrite it.
At C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\viToolkitExtensions\viToolkitExtensions.psm1:2453 char:20
+ $s | add-member <<<< -type noteproperty -name "SizeMB" -value ($totalSize / 1mb)
+ CategoryInfo : InvalidOperation: (o7%2f14%2f2010:PSObject) , InvalidOperationException
+ FullyQualifiedErrorId : MemberAlreadyExists,Microsoft.PowerShell.Commands.AddMemberCommand
Does anyone know what causes this or how to resolve it?
The problem you're seeing is that the object returned by
Get-VM <vmname> | Get-Snapshot
already contains a property called SizeMB in PowerCLI 4u1.
The easiest solution is to comment out that line in the viToolkitExtensions.psm1 file, like this
# Add this to the input object and pass it through. # $s | add-member -type noteproperty -name "SizeMB" -value ($totalSize / 1mb) $s
But in fact the complete Community Extensions need a review.
With PowerCLI 4.1 the module won't work at all since all the object types have been changed.
Btw there is no need to install VI Toolkit 1.5 and PowerCLI 4.0u1. Both are different versions of the same product.
The confusion most probably comes from the name change that occurred when PowerCLI 4.0 was released.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The problem you're seeing is that the object returned by
Get-VM <vmname> | Get-Snapshot
already contains a property called SizeMB in PowerCLI 4u1.
The easiest solution is to comment out that line in the viToolkitExtensions.psm1 file, like this
# Add this to the input object and pass it through. # $s | add-member -type noteproperty -name "SizeMB" -value ($totalSize / 1mb) $s
But in fact the complete Community Extensions need a review.
With PowerCLI 4.1 the module won't work at all since all the object types have been changed.
Btw there is no need to install VI Toolkit 1.5 and PowerCLI 4.0u1. Both are different versions of the same product.
The confusion most probably comes from the name change that occurred when PowerCLI 4.0 was released.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD, Thank you very much for the quick response!