Please Help with this Simple FSMO Role Script
hi all
please check out script below , me understand why cannot 2 separate commands merge 1 csv file. can forest fsmo role holders in 1 command, , domain role holders domains in forest in other, 1 csv proving challenge me ( bit of noob still )
i know it's simple fix, not see it.
thanks help
#======================================================================
clear
#import ad module
import-module activedirectory
#get forest
$forest = [directoryservices.activedirectory.forest]::getcurrentforest()
#get domain
$domains = [directoryservices.activedirectory.forest]::getcurrentforest().domains
#create array
$report = @()
#extract properties forest , domains
$a = $forest | select @{n="forest";e={$_}},schemaroleowner,namingroleowner
$a += $domains |select @{n="domain";e={$_}},pdc*,rid*,infra*
#populate array 2 commands above - assume both in variable $a ???. here error because types different think ( $report , $a )
$report+=$a
#generate csv
$report | export-csv "c:\fsmo.csv" -notypeinformation -useculture -force
#============================================================================
$report = @() $forest = [directoryservices.activedirectory.forest]::getcurrentforest() $domains = [directoryservices.activedirectory.forest]::getcurrentforest().domains $report += $forest | select @{n="forest";e={$_}},schemaroleowner,namingroleowner,"domain",pdcroleowner,ridroleowner,infrastructureroleowner $report += $domains |select "forest",schemaroleowner,namingroleowner,@{n="domain";e={$_}},pdc*,rid*,infra* $report | export-csv "c:\fsmo.csv" -notypeinformation -useculture -force
Windows Server > Windows PowerShell
Comments
Post a Comment