Hi,
The users and groups of the printers found are to be exported to c: \ printerreport.csv.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I found the following PowerShell script in this forum, it works very well. Is it possible to export the users and groups of the installed printers.
If possible, not the SID but the username in plain text
$ReportFileName = "c:\printerreport.csv"
$PrintServersList="c:\PrintServersList.txt"
$servers = Get-Content -Path $PrintServersList
$allprinters = @()
foreach( $server in $servers ){
Write-Host "checking $server ..."
$printers = $null
$printers = Get-WmiObject -class Win32_Printer -computername $server | select Name,Shared,ShareName,Local, DriverName, PortName,@{n="PrinterIp";e={(((gwmi win32_tcpipprinterport -ComputerName $server -filter "name='$($_.PortName)'") | select HostAddress).HostAddress)}},@{n='PrintServer';e={$_.SystemName}}, Location,Comment,SpoolEnabled,Published
$allprinters += $printers
}
Write-Host "exporting to printers.csv"
$allprinters | Export-CSV -Path $ReportFileName -NoTypeInformation -Force -Encoding UTF8
Write-Host "Done!"
Hi,
The users and groups of the printers found are to be exported to c: \ printerreport.csv.
Hi,
Do you want to get the names in the security tab? If so you can try something like this
$ReportFileName = "C:\printerreport.csv"
$PrintServersList="C:\PrintServersList.txt"
$servers = Get-Content -Path $PrintServersList
$allprinters = @()
foreach( $server in $servers ){
Write-Host "checking $server ..."
$printers = $null
$printers = Get-WmiObject -class Win32_Printer -computername $server |
select Name,Shared,ShareName,Local, DriverName, PortName,
@{n="PrinterIp";e={(((gwmi win32_tcpipprinterport -ComputerName $server -filter "name='$($_.PortName)'") | select HostAddress).HostAddress)}},
@{n='PrintServer';e={$_.SystemName}}, Location,Comment,SpoolEnabled,Published,
@{n='Trustee Name';e={($_.GetSecurityDescriptor()).Descriptor.DACL.Trustee.Name -join ','}},
@{n='Trustee SID';e={($_.GetSecurityDescriptor()).Descriptor.DACL.Trustee.SIDString -join ','}}
$allprinters += $printers
}
Write-Host "exporting to printers.csv"
$allprinters | Export-CSV -Path $ReportFileName -NoTypeInformation -Force -Encoding UTF8
Write-Host "Done!"
Note that some of the trustees have no name.
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hi IanXue-MSFT,
Great !!!
Thank you, all entries are in the CSV.
At the end, two errors are displayed
checking ...
Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Provide an argument that is not null
or empty, and then try the command again.
At C:\printerlistexport_acl.ps1:9 char:63
+ ... printers = Get-WmiObject -class Win32_Printer -computername $server |
+ ~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-WmiObject], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetWmiObjectCommand
exporting to printers.csv
Export-Csv : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\printerlistexport_acl.ps1:19 char:17
+ ... lprinters | Export-CSV -Path $ReportFileName -NoTypeInformation -Forc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Export-Csv], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ExportCsvCommand
Done!
Hi,
The error message indicates the last element of $servers is empty. Please check if there's a blank line at the end of PrintServersList.txt.
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hi,
I removed the space in PrintServersList.txt, it works.
The admin,,ALL APPLICATION PACKAGES,,CREATOR_Owner,Administrators are duplicated in printerreport.csv.
The authorization list from the printer shows
ALL APPLICATION PACKAGES = doc_manage and print
S-1-15-3-1024 = doc_manage and print
CREATOR_Owner = doc_manage
ADMIN = full
Administrators = full
hx-101= print
In the printerreport.csv
Trustee Name
hx-101,admin,admin,CREATOR_Owner,ALL APPLICATION PACKAGES,ALL APPLICATION PACKAGES,ALL APPLICATION PACKAGES,Administrators,Administrators,,,
I also tested it on different 2019 servers