Managing
multiple Active Directory domains often requires consolidated reporting.
This
PowerShell script connects to multiple AD domains, collects computer account details,
and exports the data into a CSV report with a timestamped filename.
What This
Script Does
Connects to
multiple Active Directory domains
Retrieves:
Computer Name
Operating
System
Operating
System Version
Computer
account creation date
Adds the
domain name to each record
Sorts the
results alphabetically
Exports the
data to a CSV file for reporting or audits
PowerShell Script
$domains = @("munichre.com", "munich.munichre.com","dev.munich.munichre.com", "am.munichre.com", "as.munichre.com", "eu.munichre.com")
$results = @()
foreach ($domain in $domains) {
$computers = Get-ADComputer -Server $domain -Filter * -Property Name,OperatingSystem,OperatingSystemVersion,created |
Select-Object @{Name='Domain';Expression={$domain}}, Name, OperatingSystem, OperatingSystemVersion,created
$results += $computers
}
$date = get-date -Format "dd-MM-yyyy"
$results | Sort-Object Name | Export-Csv -Path "C:\Users\ny4016117b\Desktop\AD_Computer_OS_Report_on-$date.csv" -NoTypeInformation
Output Details
The exported
CSV file will contain the following columns:
Column Name Description
Domain Active Directory domain name
Name Computer name
OperatingSystem OS installed (Windows Server / Client)
OperatingSystemVersion OS build/version
Created Computer object creation date
Prerequisites
RSAT (Remote
Server Administration Tools) installed
PowerShell
ActiveDirectory module
Sufficient
permissions to query all listed domains
Network
connectivity to domain controllers
Use Cases
OS upgrade
readiness checks
AD inventory
and audits
Compliance
reporting
Domain
consolidation planning
Tip (Optional
Enhancement)
To improve
performance in very large environments, consider:
Filtering
specific OS versions
Exporting
per-domain CSVs
Using
-SearchBase to limit OU scope
No comments:
Post a Comment
Leave your valuable words here for improve better.