Platform

Platform

A place for Apptio product users to learn, connect, share and grow together.

 View Only
Expand all | Collapse all

PowerShell cmdlet for Active Directory

Ken Haniu

Ken HaniuTue November 17, 2015 07:58 PM

Apptio Community Member

Apptio Community MemberThu March 08, 2018 01:37 PM

Apptio Community Member

Apptio Community MemberThu March 08, 2018 01:37 PM

  • 1.  PowerShell cmdlet for Active Directory

    Posted Tue November 17, 2015 04:46 PM

    When working with Windows domains networks, it is possible to use something as simple as a Powershell cmdlet to extract the entire list of servers and computers in your network

     

    So create a Powershell script similar to this one named: ASDI_ALL_ADD_SVR.ps1 for example

    Import-module ActiveDirectory
    # You need this module to extract data from AD installed (copied) to every computer form where you want to run the script

    Get -ADComputer -LDAPFilter "(&(objectcategory=computer)(OperatingSystme=*server*))"

    # This is the cmdlet you can vary upon your needs
    # In the LDAPFilter you can concatenate categories for computers in this case or other kind of equipment
    # For equipment identified by name, you can select all that include the word server on it

     

    and that is all you need to get a list of the computers/servers in your network in CSV format like below

          

     

    DistinguishedNameDNSHostNameEnabledNameObjectClassObjectGUIDSamAccountNameSID
    CN=XXXYYZZZ1,OU=Production,OU=Servers,OU=Anywhere,DC=prefix,DC=companyname,DC=suffixXXXYYZZZ1.prefix.companyname.suffixTRUEXXXYYZZZ1computerf20e9s34457-b003-4307-9572-dddcf483a5aXXXYYZZZ1$T-1-5-21-999930060-9999108022-999996952-5597
    CN=DDXXAAS1,OU=Domain
      Controllers,DC=prefix,DC=companyname,DC=suffix
    DDXXAAS1.prefix.companyname.suffixTRUEDDXXAAS1computera85bdas477c-6f38-4831-9134-46b3xxadc54DDXXAAS1$T-1-5-21-999930060-9999108022-999996952-1026
    CN=WWWAA1,OU=Domain
      Controllers,DC=prefix,DC=companyname,DC=suffix
    WWWAA1.prefix.companyname.suffixTRUEWWAA1computerb32sswcec41-39a3-448f-ed26-16c18342dxsWWAA1$T-1-5-21-999930060-9999108022-999996952-2657






    #Datalink


  • 2.  Re: Week 3&4 TBM Data Connect Contest is in Progress. Read On.

    Posted Tue November 17, 2015 07:58 PM

    Very cool, thanks Jose!

    Ken


    #Datalink


  • 3.  Re: PowerShell cmdlet for Active Directory

    Posted Thu January 05, 2017 02:33 PM

    On a Windows 7 system, you need to install RSAT (https://www.microsoft.com/en-us/download/details.aspx?id=7887), then add the AD PowerShell Module (from Windows features).

     

    Also, here is a command to export some basic information into CSV format: 

     

    Get-ADComputer -Filter * -Property * | Select-Object Name,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion | Export-CSV c:\ADComputerInvtry.csv -NoTypeInformation

     

     

    For additional data, just add the LDAP attributes (separated by commas) that you want to export to the list that follows "Select-Object" above.


    #Datalink


  • 4.  Re: PowerShell cmdlet for Active Directory

    Posted Thu March 08, 2018 01:37 PM

    Thanks Brad!


    #Datalink


  • 5.  Re: PowerShell cmdlet for Active Directory

    Posted Thu March 08, 2018 01:37 PM

    Very helpful! Thanks Jose!


    #Datalink