This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Script for Quest Powershell in order to pull data from AD

Hi All, im new to powershell and need to extract out some data.

I would like to extract below attributes from AD for a User. Could you please help me in fixing the script.


Get-QADUser t70869 | select -ObjectAttributes samAccountName, givenName, sn, displayName, description, mail,proxyaddresses,canonicalname, dn,extensionAttribute1,extensionAttribute5,extensionAttribute9,extensionAttribute14, extensionAttribute15 | export-csv C:\Users\t70869\Documents\Temp\test3.csv

SamAccountName
givenname
sn
DisplayName
Description
mail
mailNickname
ProxyAddresses
targetAddress
CanonicalName
DN
extensionAttribute1
extensionAttribute5
extensionAttribute9
extensionAttribute14
extensionAttribute15

  • Remove the -ObjectAttributes option so it's like this:

    Get-QADUser t70869 | select samAccountName, givenName, sn, displayName, description, mail,proxyaddresses,canonicalname, dn,extensionAttribute1,extensionAttribute5,extensionAttribute9,extensionAttribute14, extensionAttribute15 | export-csv C:\Users\t70869\Documents\Temp\test3.csv
  • Thank you Daniel..

    I did not got the results for below attributes..

    ProxyAddresses= System.String[]
    extensionAttribute1= Blank
    extensionAttribute5= Blank
    extensionAttribute9= Blank
    extensionAttribute14= Blank
    extensionAttribute15= Blank

    Thanks& Regards
    Samiyuddin Mohammed
  • You may have to specify the -includedproperties parameter with your Get-QAD user command and listing these so:

    Get-QADUser t70869 -includedproperties extensionAttribute1,extensionAttribute5,extensionAttribute9,extensionAttribute14,extensionAttribute15

    ...and then the rest of the code as written.
  • I'm able to extract extensionAttribute's

    But, i'm getting ProxyAddresses=System.String[]

    Get-QADUser t70869 -includedproperties extensionAttribute1,extensionAttribute5,extensionAttribute9,extensionAttribute14,extensionAttribute15| select samAccountName, givenName, sn, displayName, description, mail,proxyaddresses,canonicalname, dn,extensionAttribute1,extensionAttribute5,extensionAttribute9,extensionAttribute14, extensionAttribute15 | export-csv C:\Users\t70869\Documents\Temp\test03.csv
  • Yup, proxy addresses aree a bit trickier to deal with as you need to take that system string and convert it to a regular string.

    The line starting with $_.proxyaddresses is where that attribute gets fixed for your output.

    This is a clumsy solution but I think it will get you what you want:

    (If you don't like the '##' between the proxy addresses, just change it to something else)

    Get-QADUser t70869 -includedproperties extensionAttribute1,extensionAttribute5,extensionAttribute9,extensionAttribute14,extensionAttribute15 | %{

    $_.proxyaddresses | %{ $Addr = $_ + "##"; $AddrList = $AddrList + $Addr}

    $_ | Add-Member -MemberType NoteProperty -Name ProxyAddressString -Value $AddrList

    $_ | select samAccountName, givenName, sn, displayName, description, mail,proxyaddressString,canonicalname, dn,extensionAttribute1,extensionAttribute5,extensionAttribute9,extensionAttribute14, extensionAttribute15 | export-csv C:\Users\t70869\Documents\Temp\test03.csv -NoTypeInformation -Append

    }
  • Thanks Johnny..

    It was throwing me error when i ran above script along with " -Append"

    So, i removed "-Append" and ran the script, it was successfully completed. But, i see duplicate entry's in ProxyAddressString column. looks like all my ProxyAddresses repeated 5 times..