locked
Remove a caracter RRS feed

  • Question

  • Hello,

    I have a dilemma and i would like to know if you can put me on the right track.

    by questioning the active directory on the members of the group.


     Get-ADGroupMember -identity "ZRPI.ADMINSERVEURS.BDD" -recursive | Get-ADUser -Properties department| select name

    PS C:\windows\system32\windowspowershell\v1.0> Get-ADGroupMember -identity "ZRPI.ADMINSERVEURS.BDD" -recursive | Get-ADUser -Properties department| select name

    name    
    ----    
    MJ604328
    MJ488840
    MP522162
    MU150917
    MP523812
    MU093574
    MP509038
    ME511502
    ME479096
    ME409608
    ME515183
    ME521580
    ME525715
    ME545280


    i'm looking for everything to remove the first character from each account

    exemple MJ604328 = J604328

    PS C:\windows\system32\windowspowershell\v1.0> Get-ADGroupMember -identity "ZRPI.ADMINSERVEURS.BDD" -recursive | Get-ADUser -Properties department| select name | Get-Member


       TypeName : Selected.Microsoft.ActiveDirectory.Management.ADUser

    Name        MemberType   Definition                    
    ----        ----------   ----------                    
    Equals      Method       bool Equals(System.Object obj)
    GetHashCode Method       int GetHashCode()             
    GetType     Method       type GetType()                
    ToString    Method       string ToString()             
    name        NoteProperty string name=MJ604328        

    but, i don't know how to do it

    Do you have the means to direct me on the track to take ? 


    • Changed type jrv Tuesday, March 17, 2020 8:10 AM Wrong type
    • Edited by jrv Tuesday, March 17, 2020 8:11 AM junk in post
    Tuesday, March 17, 2020 8:04 AM

All replies

  • To remove the first character of a string just do the following.

    $newstring = $somestring.Remove(0,1)


    \_(ツ)_/

    Tuesday, March 17, 2020 8:13 AM
  • Are you asking how to change the name of an Active Directory user?

    The Rename-ADObject will do that. Changing the name may have other consequences, depending on how the name property is used in any other applications you're running in your AD Forest.


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Tuesday, March 17, 2020 3:35 PM
  • You mean like removing the 'h' from the word 'character'?
    Tuesday, March 17, 2020 8:41 PM
  • You mean like removing the 'h' from the word 'character'?

    I think the request is to specifically remove only the first character of teh name no matter wat it is.

    The easiest way si to use the code I posted above.

    The following will remove the first character of any string no matter what teh first character is:

    $newstring = $somestring.Remove(0,1)


    \_(ツ)_/

    Tuesday, March 17, 2020 8:54 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Yang Yang
    Tuesday, March 24, 2020 1:53 AM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Yang Yang

    Monday, March 30, 2020 6:00 AM