The new and updated Default Printer report is located here.
This script will find the default printer of a logged on user and write it to a text file named DefaultPrinter.txt in the %APPDATA% folder. I have this script run as a package in SCCM on a reoccurring weekly basis. This keeps the file up to date in the event a user needs a new machine or a new profile.
You can download the file from here: GetDefaultPrinter.ps1
This script will find the default printer of a logged on user and write it to a text file named DefaultPrinter.txt in the %APPDATA% folder. I have this script run as a package in SCCM on a reoccurring weekly basis. This keeps the file up to date in the event a user needs a new machine or a new profile.
You can download the file from here: GetDefaultPrinter.ps1
<#
.SYNOPSIS
Get Default Printer
.DESCRIPTION
Gets the default printer and writes the printer to a text file in the %APPDATA% folder. If
this is executed through SCCM, it must be run as the user.
.Author
Mick Pletcher
.Date
06 April 2015
.EXAMPLE
powershell.exe -executionpolicy bypass -file GetDefaultPrinter.ps1
#>
#Declare Global Variables
Set-Variable -Name DefaultPrinter -Scope Global -Force
cls
If ((Test-Path $env:APPDATA"\DefaultPrinter.txt") -eq $true) {
Remove-Item -Path $env:APPDATA"\DefaultPrinter.txt" -Force
}
$DefaultPrinter = Get-WmiObject -Class win32_printer -ComputerName "localhost" -Filter "Default='true'" | Select-Object ShareName
Write-Host "Default Printer: " -NoNewline
If ($DefaultPrinter.ShareName -ne $null) {
$DefaultPrinter.ShareName | Out-File -FilePath $env:APPDATA"\DefaultPrinter.txt" -Force -Encoding "ASCII"
Write-Host $DefaultPrinter.ShareName
} else {
$DefaultPrinter = "No Default Printer"
$DefaultPrinter | Out-File -FilePath $env:APPDATA"\DefaultPrinter.txt" -Force -Encoding "ASCII"
Write-Host $DefaultPrinter
}
#Cleanup Global Variables
Remove-Variable -Name DefaultPrinter -Scope Global -Force
0 comments:
Post a Comment