사용자 프로필 삭제 (정규 표현 식)

1835 단어 정규 표현 식
$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()

}

좋은 웹페이지 즐겨찾기