GCP Snapshot with Conditions(on the 9th snapshot delete the oldest and retain only 8)
1. #======================================================================================== # #Run Powershell as Administrator for the Extraction of Log files # #======================================================================================== param ( [ switch ] $Elevated ) function Test-Admin { $currentUser = New-Object Security.Principal.WindowsPrincipal $( [ Security.Principal.WindowsIdentity ]:: GetCurrent()) $currentUser . IsInRole( [ Security.Principal.WindowsBuiltinRole ]:: Administrator) } if (( Test-Admin ) -eq $false ) { if ( $elevated ) { # tried to elevate, did not work, aborting } else { Start-Process powershell.exe -Verb RunAs -ArgumentList ( '-noprofile -noexit -file "{0}" -elevated' -f ( $myinvocation . MyCommand . Definition)) } ...