none
Powershell script to get displayname and count characters RRS feed

  • Question

  • Hi,

    I am looking for powershell commands that will get Active directory user's display name and count it's character.any help on this much appreciated.

    Thanks!

    Karthik


    Thanks, Karthikeyan R

    Wednesday, June 28, 2017 1:25 PM

Answers

  • Get-ADUser

    Select-Object

    "String".count


    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    • Proposed as answer by jrv Wednesday, June 28, 2017 5:29 PM
    • Marked as answer by Karthikeyan44 Thursday, June 29, 2017 6:44 PM
    Wednesday, June 28, 2017 1:45 PM
  • Thanks. I stored the output to an variable and for specific attribute i used length command which gave the result.

    $Variable1 = Get-AdUser -Filter * - Properties *

    $Variable2 = ($Variable1.attributename).length

    Get-Variable $Variable2

    Thanks, Karthikeyan R

    • Marked as answer by Karthikeyan44 Thursday, June 29, 2017 6:44 PM
    Thursday, June 29, 2017 6:44 PM

All replies

  • Get-ADUser

    Select-Object

    "String".count


    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    • Proposed as answer by jrv Wednesday, June 28, 2017 5:29 PM
    • Marked as answer by Karthikeyan44 Thursday, June 29, 2017 6:44 PM
    Wednesday, June 28, 2017 1:45 PM
  • Thanks. I stored the output to an variable and for specific attribute i used length command which gave the result.

    $Variable1 = Get-AdUser -Filter * - Properties *

    $Variable2 = ($Variable1.attributename).length

    Get-Variable $Variable2

    Thanks, Karthikeyan R

    • Marked as answer by Karthikeyan44 Thursday, June 29, 2017 6:44 PM
    Thursday, June 29, 2017 6:44 PM
  • Actually I tried to be a little cheeky with you but you surprised me. Thanks. ;-)

    To make your output a little more sophisticated/professional/nice you could do it like this:

    Get-ADUser -Filter * -Properties DisplayName | 
        Select-Object -Property DIsplayName,@{Name='CharachterCount';Expression={$_.DisplayName.length}}
    


    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    Thursday, June 29, 2017 11:39 PM