testing new script

This commit is contained in:
poslop
2025-02-13 12:01:37 -06:00
parent 0f22c9530b
commit 20f22ba7f3

View File

@@ -28,6 +28,10 @@ ForEach ($computer in $ComputerName)
$loaded = $profile.Loaded
$lastUseTime = $profile.LastUseTime
$isExcluded = $False
$special = $profile.Special
If ($special) {continue}
#Calculation of the login date
$lastLoginDate = $null
@@ -54,15 +58,26 @@ ForEach ($computer in $ComputerName)
}
}
If($isExcluded) {continue}
If($isExcluded) {Write-Host "Profile $accountName was excluded!" continue}
If($InactiveDays -ne [uint32]::MaxValue -And $profileUnusedDays -le $InactiveDays){continue}
If($InactiveDays -ne [uint32]::MaxValue -And $profileUnusedDays -le $InactiveDays){
Write-Host "Skipping ""$account"" as it is recently used." -ForegroundColor Blue
Write-Host "Account SID: $sid"
Write-Host "Special system service user: $special"
Write-Host "Profile Path: $profilePath"
Write-Host "Loaded : $loaded"
Write-Host "Last use time: $lastUseTime"
If ($lastLoginDate -ne $null) { Write-Host "Last login: $lastLoginDate" }
Write-Host "Profile unused days: $profileUnusedDays"
continue}
$profilesFound ++
If ($profilesFound -gt 1) {Write-Host "`n"}
Write-Host "Start deleting profile ""$account"" on computer ""$computer"" ..." -ForegroundColor Green
Write-Host "Start deleting profile ""$account"" on computer ""$computer"" ..." -ForegroundColor Red
Write-Host "Account SID: $sid"
Write-Host "Special system service user: $special"
Write-Host "Profile Path: $profilePath"
Write-Host "Loaded : $loaded"
Write-Host "Last use time: $lastUseTime"
@@ -84,6 +99,6 @@ ForEach ($computer in $ComputerName)
}
If($profilesFound -eq 0){
Write-Warning "No profiles found on $ComputerName with Name $UserName"
Write-Warning "No profiles to delete"
}
}