Skip to content

Instantly share code, notes, and snippets.

@Nora-Ballard
Created February 15, 2014 13:56
Show Gist options
  • Select an option

  • Save Nora-Ballard/9019635 to your computer and use it in GitHub Desktop.

Select an option

Save Nora-Ballard/9019635 to your computer and use it in GitHub Desktop.
function Get-PrinterDriverFiles($ComputerName = '.')
{
$Win32_PrinterDriver = get-wmiobject -class 'Win32_PrinterDriver' -namespace 'root\CIMV2' -ComputerName $ComputerName
ForEach ($Printer in $Win32_PrinterDriver) {
$Printer.DependentFiles | ForEach-Object {
[pscustomobject] @{
"Printer" = $Printer.Name
"FullName" = $_
"Name" = Split-Path -Path $_ -Leaf
}
}
if ($Printer.ConfigFile)
{
$Printer.ConfigFile | ForEach-Object {
[pscustomobject] @{
"Printer" = $Printer.Name
"FullName" = $_
"Name" = Split-Path -Path $_ -Leaf
}
}
}
if ($Printer.DataFile)
{
$Printer.DataFile | ForEach-Object {
[pscustomobject] @{
"Printer" = $Printer.Name
"FullName" = $_
"Name" = Split-Path -Path $_ -Leaf
}
}
}
if ($Printer.DriverPath)
{
$Printer.DriverPath | ForEach-Object {
[pscustomobject] @{
"Printer" = $Printer.Name
"FullName" = $_
"Name" = Split-Path -Path $_ -Leaf
}
}
}
if ($Printer.FilePath)
{
$Printer.FilePath | ForEach-Object {
[pscustomobject] @{
"Printer" = $Printer.Name
"FullName" = $_
"Name" = Split-Path -Path $_ -Leaf
}
}
}
if ($Printer.HelpFile) {
$Printer.HelpFile | ForEach-Object {
[pscustomobject] @{
"Printer" = $Printer.Name
"FullName" = $_
"Name" = Split-Path -Path $_ -Leaf
}
}
}
}
}
#Get-PrinterDriverFiles | Out-GridView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment