Created
May 26, 2012 22:52
-
-
Save theagreeablecow/2795543 to your computer and use it in GitHub Desktop.
Server Inventory from Active Directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script will generate a list of all servers in AD, collect inventory items and export to Excel | |
# Requires the Active Directory module for Windows Powershell and appropriate credentials | |
#LOAD POWERSHELL SESSIONS | |
#------------------------ | |
$DC = "dc1.maydomain.com.au" | |
$usercredential= get-credential -credential mydomain\admin | |
$Path = "\\mydomain.com.au\Scripts\Data\" | |
$ExportFile = $Path + "ServerInventory.csv" | |
cls | |
write-host -foregroundcolor Green "Loading Active Directory Module" | |
import-module ActiveDirectory | |
#Get AD Data | |
#----------- | |
Get-ADComputer -Filter {OperatingSystem -Like "Windows *Server*"} -Property * | Select-Object Name,Enabled,Description,IPv4Address,OperatingSystem,OperatingSystemServicePack,DistinguishedName,whenCreated,LastLogonDate,whenChanged | sort name | Export-CSV $ExportFile -NoTypeInformation -Encoding UTF8 | |
#Get-ADComputer -Filter {OperatingSystem -Like "Windows *Server*"} -Property * | Export-CSV $ExportFile -NoTypeInformation -Encoding UTF8 | |
Invoke-Item $ExportFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment