header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Disable user via powershell-Help needed
Last Post 12 Jan 2010 09:28 AM by cameronove. 4 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Ash_AustraliaUser is Offline
New Member
New Member
Posts:5
Avatar

--
28 Dec 2009 09:10 PM
    Hi All,
    I am new to powershell. I have a list of about 400 users which needs to be disabled. What I want to do (as per our process):-
    1) Search for all account where samaccountname starts with HP
    2) Disable them
    3) Add zzz as prefix to the samaccountname ( e.g zzzhpabc)
    4 And set the account expiry date to the current date.

    After spending about half day on google i only managed to do below:-

    Get-user -Resultsize Unlimited | Where-Object {$_.sAMAccountName -like "hp*"} | Select-Object Name, SamAccountName, Email,  |export-csv c:\disablechange.csv

    i also tried to pipe the below with the above command to add zzz but didnt worked.

    Set-User -identity $_ -SamAccountName ($_.SamAccountName+ 'zzz')

    Any help will be highly appreciated. Thanks

    PS :- we do not have QA commandlets.
    Cheers
    Regards
    Ash

    DatacomUser is Offline
    New Member
    New Member
    Posts:27
    Avatar

    --
    05 Jan 2010 03:51 PM
    I have similar questions as well. Can anyone shed some light on how to do it with quest cmdlets. Thanks
    cameronoveUser is Offline
    Basic Member
    Basic Member
    Posts:332
    Avatar

    --
    12 Jan 2010 09:16 AM
    Try:

    get-qaduser -includedproperties samaccountname,accountexpires -ldapfilter '(samaccountname=hp*)' | foreach{$_.samaccountname = "zzz$($_.samaccountname)";$_.accountexpires = (get-date);$_.commitchanges()}
    cameronoveUser is Offline
    Basic Member
    Basic Member
    Posts:332
    Avatar

    --
    12 Jan 2010 09:18 AM
    I edited my previous post but just in case you are getting this via email here is the corrected version


    get-qaduser -includedproperties samaccountname,accountexpires -ldapfilter '(samaccountname=hp*)' | foreach{$_.samaccountname = "zzz$($_.samaccountname)";$_.accountexpires = (get-date);$_.commitchanges()}
    cameronoveUser is Offline
    Basic Member
    Basic Member
    Posts:332
    Avatar

    --
    12 Jan 2010 09:28 AM
    oops forgot to disable:

    get-qaduser -includedproperties samaccountname,accountexpires -ldapfilter '(samaccountname=hp*)' | foreach{$_.samaccountname = "zzz$($_.samaccountname)";$_.accountexpires = (get-date);$_.commitchanges();disable-qaduser $_.distinguishedName}
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer