########################################################################### # NAME: Script to disable users account and move them to different OU using CSV # AUTHOR: Imran Pathan # COMMENT: All you need is fill up the Disable user account csv with saMAccountName & OU to move to. # VERSION HISTORY: 1.0 # 1.0 12/19/2012 - Initial release ############################################################################ $UsersToDisbableList=IMPORT-CSV C:\Imran\DisableUsers.csv $PrimaryDC = 'PDC002.yourdomain.local' $DomainName = 'yourdomain' Clear-Host Connect-QADService -service $PrimaryDC Function DisableUsers { Param( [string] $_SamAccountName, [string] $_MoveTOOU ) write-host ("User: $_SamAccountName") Write-Host ("Move to OU: $_MoveTOOU") Get-ADUser $_SamAccountName | Set-ADUser -Enabled $false Start-Sleep -s 2 Move-QADObject -Identity $_SamAccountName -NewParentContainer $_MoveTOOU Start-Sleep -s 2 } FOREACH ($User in $UsersToDisbableList) { DisableUsers $User.SamAccountName $User.MoveTOOU }
6/3/14
PowerShell to Disable users account & move them to different OU using CSV
Đăng ký:
Đăng Nhận xét (Atom)
Không có nhận xét nào:
Đăng nhận xét