As a follow up to my last post on GPP, and per request on Technet, I’ve now created Another script to make inventory of all printers in a domain deployed with GPO (both GPP and Deployed Printers). It can be a pain to use those settings some times, here you have a way to make inventory of them at least. 🙂
Just like the other one it’s based on the GroupPolicy PowerShell-Module which works from 2008R2 and up.
See below screenshots on how to run the script and what output you get. (similiar to the GPP Drive maps output)
If you want to export all printer information to a csv file, use below row.
.\Get-GPOPrinters.ps1 | select printerpath,gpotype,gponame,FilterGroup | Export-Csv c:\printers.csv -NoTypeInformation
Get-GPOPrinters.ps1
<# .SYNOPSIS The script finds all shared printers deployed with GPO (both deployed printers GPP.) in your domain. .NOTES File Name: Get-GPOPrinters.ps1 Author : Johan Dahlbom, johan[at]dahlbom.eu The script are provided “AS IS” with no guarantees, no warranties, and it confer no rights. Blog : 365lab.net #> #Import the required module GroupPolicy try { Import-Module GroupPolicy -ErrorAction Stop } catch { throw "Module GroupPolicy not Installed" } $GPO = Get-GPO -All foreach ($Policy in $GPO){ $GPOID = $Policy.Id $GPODom = $Policy.DomainName $GPODisp = $Policy.DisplayName $PrefPath = "\\$($GPODom)\SYSVOL\$($GPODom)\Policies\{$($GPOID)}\User\Preferences" #Get GP Preferences Printers $XMLPath = "$PrefPath\Printers\Printers.xml" if (Test-Path "$XMLPath") { [xml]$PrintXML = Get-Content "$XMLPath" foreach ( $Printer in $PrintXML.Printers.SharedPrinter ) {New-Object PSObject -Property @{ GPOName = $GPODisp PrinterPath = $printer.Properties.Path PrinterAction = $printer.Properties.action.Replace("U","Update").Replace("C","Create").Replace("D","Delete").Replace("R","Replace") PrinterDefault = $printer.Properties.default.Replace("0","False").Replace("1","True") FilterGroup = $printer.Filters.FilterGroup.Name GPOType = "Group Policy Preferences" } } } #Get Deployed Printers [xml]$xml = Get-GPOReport -Id $GPOID -ReportType xml $User = $xml.DocumentElement.User.ExtensionData.extension.printerconnection $Computer = $xml.DocumentElement.computer.ExtensionData.extension.printerconnection foreach ($U in $User){ if ($U){ New-Object PSObject -Property @{ GPOName = $GPODisp PrinterPath = $u.Path GPOType = "GPO Deployed Printer - User" } } } foreach ($C in $Computer){ if ($c){ New-Object PSObject -Property @{ GPOName = $GPODisp PrinterPath = $c.Path GPOType = "GPO Deployed Printer - Computer" } } } }
This was done very quick, will probably do some things a bit nicer later on. If you find any direct issues or bugs, let me know!
Enjoy!
/Johan