header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
change Password for any AD-Users
Last Post 01 Aug 2010 11:05 AM by 0ptikGhost. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
aceUser is Offline
New Member
New Member
Posts:4
Avatar

--
29 Jul 2010 04:51 AM
    Hey @all

    iám a beginner in PS . I try to create a script which change passwords from all Users in OU "Admin Group "(AD).The users should all get the same password.

    First step...i search the users:

    Get-ADUser - Filter {sAMAccountName -like "*"} | Where-Object {$_.DistinguishedName -like "*Admins*"} | Select-Object sAMAccountName

    Output:

    sAMAccountName
    ---------------------
    user1
    user2
    user3

    other option:

    Get-ADUser -filter 'samAccountName -like "*"' | where-Object {$_.DistinguishedName -like "*Admins*"} | where-Object {write-host $_.SamAccountName}

    Output:

    user1
    user2
    user3

    i think perfect but i can´t save this in a variable! why ?



    How can I only have to spend the users? Without the Headline!
    Then i will put the result into a variable!

    If this is done...i need script to change the passwords....
    like this... only for all users...

    Set-ADAccountPassword -Identity user1 -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Password123" -Force)

    Individual that works quite well...

    can someone help me?

    thx
    alex




    0ptikGhostUser is Offline
    Basic Member
    Basic Member
    Posts:296
    Avatar

    --
    01 Aug 2010 11:05 AM

    Where-Object performs a filter test allowing only those objects through onto the next portion of the pipeline if the condition is true. Use Foreach-Object or Select-Object -ExpandProperty.

    Get-ADUser -Filter {sAMAccountName -like "*"} | Where-Object {$_.DistinguishedName -like "*Admins*"} | Select-Object -ExpandProperty sAMAccountName Get-ADUser -Filter {sAMAccountName -like "*"} | Where-Object {$_.DistinguishedName -like "*Admins*"} | Foreach-Object -Process {$_.sAMAccountName}

    If the Set-ADAccountPassword takes the -Identity parameter by pipeline then you could probably do this:

    Get-ADUser -Filter {sAMAccountName -like "*"} | Where-Object {$_.DistinguishedName -like "*Admins*"} | Select-Object -ExpandProperty sAMAccountName | Set-ADAccountPassword -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Password123" -Force)

    If it can't then perhaps you should use Foreach-Object.

    Get-ADUser -Filter {sAMAccountName -like "*"} | Where-Object {$_.DistinguishedName -like "*Admins*"} | Foreach-Object -Process { Set-ADAccountPassword -Identity $_.sAMAccountName -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "Password123" -Force) }
    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