locked
Export CSV for AD computers DNSHostname, Description, Enabled. I can run the data pull but I am unable to export. I have not exported data before. RRS feed

  • Question

  • Get-ADComputer -filter * -SearchBase 'OU=US,OU=NA,DC=sealedair,DC=corp' -Properties Description | ? DistinguishedName -like '*OU=Workstations*' | Select DNSHostname, Description, Enabled

    Export-Csv output.csv -Delimiter ";" -Encoding UTF8 -Force  -NoTypeInformation
    Thursday, August 10, 2017 1:29 AM

All replies

  • You are not exporting anything.  You must provide something to the Export-Csv command. Have you looked at the output on the console?  What does it say?


    \_(ツ)_/

    Thursday, August 10, 2017 1:36 AM
  • Here is where I am confused. I just recently started working with PS. I normally work in our networking group and wanted to pull some info from AD for a project Im on but I was lucky to get the data so far. Im on limited time unfortunately. So what Im trying to say is I need help knowing how to retrieve the output on the console.. ha
    Thursday, August 10, 2017 1:48 AM
  • Is

    Get-ADComputer -filter * -SearchBase 'OU=US,OU=NA,DC=sealedair,DC=corp' -Properties Description | ? DistinguishedName -like '*OU=Workstations*' | Select DNSHostname, Description, Enabled

    The most effective way to retrieve this info needed?

    Thursday, August 10, 2017 1:53 AM
  • Why don't you just send the output from the first line into the second line in the pipeline?  Why do you want it on the console.  Export-Csv cannt output what is displayed on the console.

    Start by using help to learn how the CmdLets work.  This is like "technology 101".  Use hell.

    help export-csv -full

    I recommend that you start by learning basic PowerShell.  No experienced technician would try to guess at how to use a technology.  You must do your homework first.

    Pipe the output into the Export command and all will be well.


    \_(ツ)_/

    Thursday, August 10, 2017 1:55 AM
  • Is

    Get-ADComputer -filter * -SearchBase 'OU=US,OU=NA,DC=sealedair,DC=corp' -Properties Description | ? DistinguishedName -like '*OU=Workstations*' | Select DNSHostname, Description, Enabled

    The most effective way to retrieve this info needed?

    No.  It is not even a correct usage of the command. "SearchBase" is the "OU" being queried.  Start by learning AD and how it is structured.  You want "SearchBase" to target he OU.  You do not want to filter anything.


    \_(ツ)_/

    Thursday, August 10, 2017 1:57 AM
  • I will do abit more research. This was for a quick need and will be very interested to learn more. I appreciate the words of wisdom.

    Thank you. 

    Thursday, August 10, 2017 1:58 AM
  • Boy I feel silly, I will look in to this. I usually wouldnt create a thread clueless but I was getting frustrated with all the info online and finding issues at every turn. Normally this wouldnt bother me and would be fun but I have a time crunch. I will definitely dive in to this though. I apologize that I am not prepared for your questions. I appreciate the help very much.
    Thursday, August 10, 2017 2:06 AM
  • Start by running just the basic command and looking at the output.  Use your mind and your senses to learn how things work.  Look up all terms and things you don't understand.  This is how to be a technician and not just an operator.

    Get-ADComputer -filter * -SearchBase 'OU=WorkStations,OU=US,OU=NA,DC=sealedair,DC=corp'

    What do you get?  What do you see?

    A little study of how AD works would also be helpful.


    \_(ツ)_/

    Thursday, August 10, 2017 2:14 AM
  • PS C:\MyScripts_Powershell> Get-ADComputer -filter * -SearchBase 'OU=WorkStations,OU=US,OU=NA,DC=sealedair,DC=corp'
    Get-ADComputer : Directory object not found
    At line:1 char:1
    + Get-ADComputer -filter * -SearchBase 'OU=WorkStations,OU=US,OU=NA,DC=sealedair,D ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (:) [Get-ADComputer], ADIdentityNotFoundException
        + FullyQualifiedErrorId : Directory object not found,Microsoft.ActiveDirectory.Management.Commands.GetADComputer

    Thursday, August 10, 2017 2:19 AM
  • help  Get-ADComputer  -full

    First learn how AD works or you will just be going in circles.  You have to stop trying toguess how to do this.  We cannot help you and you cannot understand the answers if you do not know the technologies you are trying to script.


    \_(ツ)_/

    Thursday, August 10, 2017 2:22 AM
  • I agree, I still appreciate your time. 

    Thank you.

    Thursday, August 10, 2017 2:22 AM