Solved

PowerShell Group Policy Reports

Posted on 2013-12-04
5
412 Views
1 Endorsement
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
1
Comment
Question by:litog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 25

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
1

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Issue: One Windows 2008 R2 64bit server on the network unable to connect to a buffalo Device (Linkstation) with firmware version 1.56. There are a total of four servers on the network this being one of them. Troubleshooting Steps: Connect via h…
Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

690 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