1 2 3 4 5 6 |
$usuarios = ls C:\Users | where {$_.LastAccessTime -lt (Get-Date).AddDays(-10)} | select -ExpandProperty name foreach ($usuario in $usuarios) { $usuario Get-WmiObject win32_userprofile | where {!$_.special -and $_.LocalPath.split('\')[2] -eq $usuario} | Remove-WmiObject -WhatIf } |