04 February 2019

Default Printer Report

When our build team builds new machines for users, we provide a convenience to the user of letting them know what their default printer is. I wrote this script that will parse through all user profiles in HKU to find the default printer of each profile. It will then write the results to the screen if the script is manually executed, while also writing to the DefaultPrinter.CSV file located at the default directory of each user profile. This allows for the script to be deployed through SCCM, or be executed remotely or locally with PowerShell. The reason I have it write to a CSV file instead of reporting to SCCM is that not everyone has access to SCCM and for universal compatibility, not all companies have SCCM.

I deployed this script through a package in SCCM that is scheduled to execute once a week. Every time this script executes, it will replace the current file with a new one.

You can download the script from here.


 <#  
      .SYNOPSIS  
           Default Printer Report  
        
      .DESCRIPTION  
           This script will retrieve a list of all user profiles and report to a text file inside each user profile what the default printer is.   
        
      .NOTES  
           ===========================================================================  
           Created with:     SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.142  
           Created on:       2/4/2019 8:56 AM  
           Created by:       Mick Pletcher  
           Filename:         DefaultPrinterReport.ps1  
           ===========================================================================  
 #>  
   
 [CmdletBinding()]  
 param ()  
   
 $Profiles = (Get-ChildItem -Path REGISTRY::HKEY_USERS -Exclude *Classes | Where-Object {$_.Name -like '*S-1-5-21*'}).Name  
 $ProfileArray = @()  
 foreach ($Item in $Profiles) {  
      $object = New-Object -TypeName System.Management.Automation.PSObject  
      $object | Add-Member -MemberType NoteProperty -Name Profile -Value ((Get-ItemProperty -Path ('REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\' + ($Item.split('\')[1].Trim())) -Name ProfileImagePath).ProfileImagePath).Split('\')[2]  
      $object | Add-Member -MemberType NoteProperty -Name DefaultPrinter -Value ((Get-ItemProperty -Path ('REGISTRY::' + $Item + '\Software\Microsoft\Windows NT\CurrentVersion\Windows') -Name Device).Device).Split(',')[0]  
      $ProfileArray += $object  
 }  
 $ProfileArray
 foreach ($Item in $ProfileArray) {  
      Export-Csv -InputObject $Item -Path ($env:SystemDrive + '\users\' + $Item.Profile + '\DefaultPrinter.csv') -NoTypeInformation -Force  
 }  
   

Related Posts:

  • Java Runtime Environment Installation Script This VB script I wrote will uninstall all previous versions of Java Runtime Environment. It will also install both the x86 and x64 versions, depending on whether the OS is 64-bit compatible. It uses the msi installer, which … Read More
  • USMT 4.0 PC-to-PC Migration Script This script will execute the USMT, migrating data from the old machine to the new machine. Both PCs must be on the network. You will be prompted to enter the old computer name, new computer name, and the username. This is t… Read More
  • List all systems that are logged off I wrote this script in 2010 to be able to give me a list of systems that are currently logged off from a list of computers in a text file. My purpose for this was to be able to find systems to test software deployments on in… Read More
  • Customizing the ZTIBiosCheck.wsf file for MDT/SCCM As there is not much documentation on how to use the ZTIBiosCheck.wsf file with MDT/SCCM, I had to figure a lot of it out. The WSF file retrieves the BIOS data via WMI queries to compare against the data stored in the ZTIBIO… Read More
  • List Installed Windows 7 Updates You are looking for a list of all installed updates on a machine for either identifying what has not been installed, or like myself, to find the list so that you know what is needed to download to include in the MDT/SCCM bui… Read More

0 comments:

Post a Comment