Functions/Get-UserProfiles.ps1
function Get-UserProfiles { [CmdletBinding()] param ( ) $Profiles = Get-CimInstance Win32_UserProfile $ProfilesFiltered = $Profiles | Where-Object { $_.LastUseTime -and $_.Special -eq $false } # $Profiles | Select-Object LocalPath, LastUseTime, SID, Loaded, Special, HealthStatus | ft return $ProfilesFiltered } # Get-UserProfiles | Where-Object { $_.LastUseTime -lt (Get-Date).AddDays(-180) } | Remove-CimInstance |