-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathDefaultPrinterReport.ps1
31 lines (27 loc) · 1.51 KB
/
DefaultPrinterReport.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<#
.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
}