I have collected the codes which is collecting Snapshot Name,Descrition,Size, create Date and Creator ( owner of snapshot)
However is any scheduled snapshot found in any VM and it has more than 2 then the Creator output is not coming with null user and it should show only the users related to snapshot
the reports getting auto filled in the null field of creator
I have collected the codes which is collecting Snapshot Name,Descrition,Size, create Date and Creator ( owner of snapshot) However is any scheduled snapshot found in any VM and it has more than 2 then the Creator output is not coming with null user and it should show only the users related to snapshot
the reports getting auto filled in the null field of creator
Can anyone help on this?
Format html report
$htmlReport = @"
<table border=0 cellpadding=0 cellspacing=0 width=600 style='border-collapse:collapse;table-layout:fixed;width:600pt'>
"@
$today = Get-Date
$vmlist = Get-VM -Server $server
$snapshotCount = 0
$snapshot=get-snapshot | where {$.Created -le ($today.addDays(-4))} -WarningAction SilentlyContinue foreach ($snap in $snapshot){ $snapevent = Get-VIEvent -Entity $snap.VM -Types Info -Finish (( get-date $snap.Created).addhours(1))|Where-Object {$.UserName -notlike 'AXE\rubrikvadpr*'}|Where-Object {$.UserName -notlike 'AXE\rubrik_vadp'} | Where-Object {$_.FullFormattedMessage -imatch ‘Task: Create virtual machine snapshot’} | sort createdtime -Descending | select -First 1 if ($snapevent -ne $null){ $new1, $new2 = $snapevent.UserName.Split( "\") $us=Get-ADUser $new2|Select-Object Name
$snapshotCount = $snapshotCount + 1 $htmlReport = $htmlReport +
"
} }
$htmlReport = $htmlReport + "" $htmlReport | Out-File "C:\temp\snapshot Report.html"
Disconnect-VIServer -Server $server -Force:$true -Confirm:$false