testing new script
This commit is contained in:
@@ -28,6 +28,10 @@ ForEach ($computer in $ComputerName)
|
|||||||
$loaded = $profile.Loaded
|
$loaded = $profile.Loaded
|
||||||
$lastUseTime = $profile.LastUseTime
|
$lastUseTime = $profile.LastUseTime
|
||||||
$isExcluded = $False
|
$isExcluded = $False
|
||||||
|
$special = $profile.Special
|
||||||
|
|
||||||
|
|
||||||
|
If ($special) {continue}
|
||||||
|
|
||||||
#Calculation of the login date
|
#Calculation of the login date
|
||||||
$lastLoginDate = $null
|
$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 ++
|
$profilesFound ++
|
||||||
|
|
||||||
If ($profilesFound -gt 1) {Write-Host "`n"}
|
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 "Account SID: $sid"
|
||||||
|
Write-Host "Special system service user: $special"
|
||||||
Write-Host "Profile Path: $profilePath"
|
Write-Host "Profile Path: $profilePath"
|
||||||
Write-Host "Loaded : $loaded"
|
Write-Host "Loaded : $loaded"
|
||||||
Write-Host "Last use time: $lastUseTime"
|
Write-Host "Last use time: $lastUseTime"
|
||||||
@@ -84,6 +99,6 @@ ForEach ($computer in $ComputerName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
If($profilesFound -eq 0){
|
If($profilesFound -eq 0){
|
||||||
Write-Warning "No profiles found on $ComputerName with Name $UserName"
|
Write-Warning "No profiles to delete"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user