###################################################################################
#This Script has made to fetch all domain information Including Master Roles and Number of user#
#Into a CSV (Comma separated Value) #
################################################################################
$Domains=Get-ADForest | select domains -ExpandProperty domains
$OutputObj = New-Object -Type PSObject -ErrorAction Stop
$i=0;
foreach($domain in $Domains)
{
$i=$i+1;
Write-Host $i;
$domaininfo = Get-ADDomain -Server $Domain | select name,ParentDomain,PDCemulator,RIDmaster
$numberofusers=(Get-ADUser -Filter * -Server $domain |select name).count
Write-Host -ForegroundColor Cyan "$Domain consists $numberofusers user account"
####################################################################################################
#Import to a CSV file
$OutputObj | Add-Member -MemberType NoteProperty -Name DomainName -Value $domain.ToUpper() -Force
$OutputObj | Add-Member -MemberType NoteProperty -Name Name -Value $domaininfo.name -Force
$OutputObj | Add-Member -MemberType NoteProperty -Name ParentDomain -Value $domaininfo.ParentDomain -Force
$OutputObj | Add-Member -MemberType NoteProperty -Name PDCemulator -Value $domaininfo.PDCemulator -Force
$OutputObj | Add-Member -MemberType NoteProperty -Name RIDmaster -Value $domaininfo.RIDmaster -Force
$OutputObj | Add-Member -MemberType NoteProperty -Name UserCount -Value $numberofusers -Force
$OutputObj |Export-Csv C:/temp/Domaininfoanduser_count.csv -Append -Encoding UTF8
}
#This Script has made to fetch all domain information Including Master Roles and Number of user#
#Into a CSV (Comma separated Value) #
################################################################################
$Domains=Get-ADForest | select domains -ExpandProperty domains
$OutputObj = New-Object -Type PSObject -ErrorAction Stop
$i=0;
foreach($domain in $Domains)
{
$i=$i+1;
Write-Host $i;
$domaininfo = Get-ADDomain -Server $Domain | select name,ParentDomain,PDCemulator,RIDmaster
$numberofusers=(Get-ADUser -Filter * -Server $domain |select name).count
Write-Host -ForegroundColor Cyan "$Domain consists $numberofusers user account"
####################################################################################################
#Import to a CSV file
$OutputObj | Add-Member -MemberType NoteProperty -Name DomainName -Value $domain.ToUpper() -Force
$OutputObj | Add-Member -MemberType NoteProperty -Name Name -Value $domaininfo.name -Force
$OutputObj | Add-Member -MemberType NoteProperty -Name ParentDomain -Value $domaininfo.ParentDomain -Force
$OutputObj | Add-Member -MemberType NoteProperty -Name PDCemulator -Value $domaininfo.PDCemulator -Force
$OutputObj | Add-Member -MemberType NoteProperty -Name RIDmaster -Value $domaininfo.RIDmaster -Force
$OutputObj | Add-Member -MemberType NoteProperty -Name UserCount -Value $numberofusers -Force
$OutputObj |Export-Csv C:/temp/Domaininfoanduser_count.csv -Append -Encoding UTF8
}
No comments:
Post a Comment