Hi All
I have created a Powershell script that checks for Orphaned Files and Invalid Snapshot images.
The Orphaned Files part of the check is using Luk Dekens function for finding and removing phantom files available here.
The other part of the script checks for servers that are using snapshots that do not exist in snapshot manager or servers which have a Consolidated Helper snapshot.
We currently run this script daily and it sends us an email if it finds any problems.
Simply alter the variables in the top part of the script and it should be able to run in any environment that has PowerCLI installed.
Nice script, thanks for sharing.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sorry for being dumb.. but how do I modify the script to use my environment?
Which lines do I put in my datastore name(s), the "test run", etc?
You only have to edit the variables in the top section of the script to specify the virtual centre server and who you want to email the report to.
By default it checks all datastores in vcenter.
The script doesn't perform any activity on the datastores or files it will just generate and email out a report on any issues it might find.
(well it can also delete orphaned files but only if you add the -Delete switch to the Check-OrphanedData command)
Hi Grant & Luc
Thanks for a great script. I do need some help with it please. I've modified the script variables but get the following when running with PowerCLi 5.5 R2 and VC 5.5 U1c
PowerCLI C:\PS> .\Get-Snap.ps1
Get-HardDisk : 04/09/2014 08:32:29 Get-HardDisk System error.
At C:\PS\Get-Snap.ps1:300 char:19
+ $vm | Get-HardDisk | %{
+ ~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-HardDisk], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.GetHardDisk
Get-HardDisk : 04/09/2014 08:32:38 Get-HardDisk System error.
At C:\PS\Get-Snap.ps1:300 char:19
+ $vm | Get-HardDisk | %{
+ ~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-HardDisk], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.GetHardDisk
Get-HardDisk : 04/09/2014 08:32:38 Get-HardDisk System error.
At C:\PS\Get-Snap.ps1:300 char:19
+ $vm | Get-HardDisk | %{
+ ~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-HardDisk], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.GetHardDisk
Any advise?
Thanks
Johan
Hi,
My PowerCLI output is the same tna your, but I got the report, nonetheless.
regards.
It would be interesting to know for which VMs you get these errors.
Perhaps display the name of the VM on screen before the Get-Harddisk cmdlet is executed.
I suspect these VMs might have a funny configuration.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You may need to consolidate the disks. See the following for more information: Re: Virtual Machine Disks consolidation is needed
Seeing errors/warnings with this script I assume because it's older..
I suspect you are connected to multiple vSphere servers in multiple mode (see Get-PowerCLIConfiguration)
As a result $dsBrowser will contain multiple object, and is in fact an array.
And the SearchDatastoreSubFolders method is not known on an array (that is in fact what the error is saying)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You are correct I had logged into VC before executing the script which resulted in that outcome. Looks like its working now. This script will only show INVALID snapshots and not VALID snapshots correct?
That is correct.
Like the author explained "The other part of the script checks for servers that are using snapshots that do not exist in snapshot manager or servers which have a Consolidated Helper snapshot."
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I got the same problem with the Get-HardDisk pipe, here is the fix:
Just replace these 2 lines
$vm | Get-HardDisk | %{
if ($_.Filename -match ".*-[0-9]{6}.vmdk")
with
foreach ($hd in $vm | Get-HardDisk) {
if ($hd.Filename -match ".*-[0-9]{6}.vmdk")
I believe something weird is happening in the object pipe with the original version
Hi Guys,
I need to detect and report only without deletion, any idea?
Best Regards
Afaik this script only reports and doesn't do any deletes
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference