首页 > 其他 > 详细

删除用户配置文件 (正则表达式)

时间:2015-05-11 10:21:53      阅读:186      评论:0      收藏:0      [点我收藏+]
$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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!