Solved

PowerShell Group Policy Reports

Posted on 2013-12-04
5
378 Views
Last Modified: 2014-10-06
Hello,

I'm attempting to get a good report in Excel for over 300 group policies.  I'd also like to get these in on one excel sheet so that I can sort, and view to find duplicate settings that I can combine. I'm finding this isn't as easy as I thought it was going to be. I tried exporting a report using get-gporeport but the export of the gporeport.xml doesn't open up good at all in excel, plus I don't want to open up each report manually and copy the contents over.

I also looked at SDM, but there is no budget for that so I have to look at scripts to do this.

I'm extremely new to scripting and still don't quite understand the scripting language but have tried the following to export some of the contents in the XML file.

Script so far
$xml = [xml](get-content 'C:\temp\gpo\gpreport.xml')
$xml.GPO | foreach {$_.Name + ":" + $_.CreatedTime + ":" + $_.User.Enabled + ":" + $_.User.ExtensionData.Name}

Results
IT EXPLORER:2008-05-13T18:44:40:true:Internet Explorer Maintenance Registry

Am I doing this correctly? What I want is to export the name, owner, created date, and the settings name, and settings for each of the policies, disabled or not, linked or not, etc...

Thanks
Lito
0
Comment
Question by:litog
5 Comments
 
LVL 24

Accepted Solution

by:
Coralon earned 500 total points
ID: 39719029
You are on the right track from what I can see (I'm not at work, so I can't generate my own GPO report to see the XML.  Can you load a sample of the XML data?)  I need to know what it looks like, but you can make some optimizations.

[xml]$xml = new-object -typename xml
$xml.load('C:\temp\gpo\gpreport.xml')

$xml.gpo | foreach {
     ($_.Name, $_.CreatedTime, $_.User.Enabled, $_.User.ExtensionData.Name) -join ':'
}

Open in new window


1. Using the $xml.load is substantially faster than using get-content.  The more policies and settings you are dealing with, the more you will notice it.  (I've seen it listed as 7 times faster).
2. The -join is faster and easier then using regular concatenation.  Without the XML file, I can't be 100% sure of the needed syntax, but digging through something similar I have done before... I did this:
$xml.Folders | foreach {($_.Folder.AppFolder) -join ':'}

Open in new window


The XML source was similar to this:
<Folders>
     <Folder AppFolder='Folder1'> 
     </Folder>
     <Folder AppFolder='Folder2'> 
     </Folder>
</Folders>

Open in new window


The key is that you are working with XML elements. The AppFolder attribute outputs as a string, so you can use -join with it.  

Coralon
0

Featured Post

Promote certifications in your email signature

Has your company recently won an award or achieved a certification? They'll no doubt want to show it off. Email signature images used to promote certifications & awards can instantly establish credibility with a recipient and provide you with numerous benefits.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now