I have a task to get all GPOs from each sub domain and present them in Excel for upper Management (Count per domain, Count per user, count per Computer,..)
Managing the exported data in Excel is not that issue (using the Excel Com objects), but with my old school VBScript looping technology it looks pretty hefty... How to get it more PowerShell like?
This section would run 3 times (3 domain calls) and currently overwrites the array $GPOArray with the last run.
Code:
Import-Module
GroupPolicy
$DomainList = @("company.com","sales.company.com","production.company.com")
foreach ($Domain in $DomainList) {
}
My idea to use a hash Table unsing an child foreach loop was not successful as i'm using the same fields and overwrote them
I would like to create one array with all the IDs, DisplayName and GPO Status as an object to fill the data into Excel.
Better strategy to start with opening Excel and write directly into the sheet?
Still need to adjust to the more elegant way...
When i write directly to an Excel object, the $GPO.GPOStatus is enteres as a Int32 value. PowerShell itself displays as AllSettingsEnabled|UserSettingsDisabled|...
is there a quick way (other then a select loop) to enter the text into excel?