$parttern = "\b\d{6}\b" $today = Get-Date $hostname = "cnhzpd-47d173x" $profiles = Get-WmiObject -Class win32_userprofile -ComputerName $hostname | Select-Object -Property LocalPath, @{N=‘time‘; E={$_.ConverttoDateTime($_.lastusetime)}}, @{N=‘Delta‘;E={$today - $_.ConverttoDateTime($_.lastusetime)}} | where {$_.localpath.substring(9,6) -match $parttern -and $_.delta -gt ‘6.0:0:0‘} foreach($profile in $profiles) { (Get-WmiObject -class Win32_UserProfile -ComputerName $hostname | where {$_.localpath -eq $profile.localpath}).delete() }
时间: 2024-10-05 03:26:49