标签:
$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() }
标签:
原文地址:http://www.cnblogs.com/IvanChen/p/4493714.html