Commit c03a7188 authored by Brant Wells's avatar Brant Wells
Browse files

Misc Updates.

Updated snapshotCleanup.ps1
parent 4c28a48f
{
"workbench.editor.highlightModifiedTabs": true
"workbench.editor.highlightModifiedTabs": true,
"powershell.codeFormatting.addWhitespaceAroundPipe": true
}
\ No newline at end of file
......@@ -85,7 +85,7 @@ foreach ($searchString in $search) {
#if ($displayWindow -eq $true) { $users|Out-GridView } else {$users|ft -AutoSize}
if ($displayWindow -eq $true) {
$userList|Out-GridView -Title "Details for $search"
$userList|select *|Out-GridView -Title "Details for $search"
} else {
$userList | select DisplayName, UserPrincipalName, SamAccountName, Description, Created, AccountExpirationDate, Department, EmployeeID, EmployeeNumber, Enabled, LastLogonDate, LockedOut, Modified, OfficePhone, PasswordLastSet, PasswordNeverExpires,OtherPager, OtherFacsimileTelephoneNumber |ft -auto
}
......
......@@ -5,6 +5,7 @@ This command is meant to add clean up snapshots that are generated on a Daily ba
.DESCRIPTION
Date Updated By Details
05-21-2020 BW Modified to show whether we are listing or removing snapshots.
11-07-2019 BW Updated script to track number of snapshots to delete per VM.
10-30-2019 BW Added Logging mechanism with start/stop-transcript
10-29-2019 BW Initial release. Parameters set to clean Any daily snaphots older than 8 days.
......@@ -30,7 +31,7 @@ Param(
#the default progress bar is useless for this. Disable it!
$origProgressBar = $ProgressPreference
$ProgressPreference = "SilentlyContinue"
if ($liveRun -eq $false) {$action="Listing"} else {$action = "Cleaning"}
#vmware initialization
$hasVI=get-command connect-viserver* -ErrorAction SilentlyContinue
......@@ -86,15 +87,11 @@ if ($cleanAll -eq $true) {
write-host "Found $($vmName.count) machines to clean..."
}
if ([string]::IsNullOrEmpty($logFile)) {
$logFile="snapshotCleanup_$(get-date -format "MMddyyyy_HHmmss").log"
#read-host "Log file says $logFile"
}
$logFile="snapshotCleanup_$(get-date -format "MMddyyyy_HHmmss").log"
if ($liveRun -eq $true) {start-transcript -Path $logFIle -Append }
foreach ($vm in $vmName) {
write-host "Cleaning snapshots for $vm"
write-host "$action snapshots for $vm"
if ($liveRun -eq $true) {
$objVM=get-vm $vm
$objSnapshots=$objVM | get-snapshot|where {$_.Name -like "*$cleanupMatch*" -and $_.created -lt $keepDate}
......@@ -110,7 +107,7 @@ foreach ($vm in $vmName) {
get-vm $vm | get-snapshot | where { $_.Name -like "*$cleanupMatch*" -and $_.created -lt $keepDate } | Select Created,Name|ft
}
write-host "Done Removing snapshots for $vm"
write-host "Done $action snapshots for $vm"
write-host " "
}
if ($liveRun -eq $true) { Stop-Transcript }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment