Permission to change the printer name.

Samuel Freitas 0 Reputation points
2024-05-15T21:00:41.1666667+00:00

I need to change the name of my printer to be recognized in a function for my system. I'm not very good at programming, but with AI I managed to execute this command within PowerShell:

att. Language code-comment portuguese-Brazil.

PS C:\WINDOWS\system32> # Defina a parte do nome que você deseja identificar na impressora
>> $parteDoNome = "TECTOY"
>>
>> # Defina o novo nome que você deseja atribuir às impressoras
>> $novoNome = "TESTE"
>>
>> # Obtenha todas as impressoras cujos nomes contêm a parte específica
>> $impressoras = Get-Printer | Where-Object { $_.Name -like "*$parteDoNome*" }
>>
>> # Percorra cada impressora e renomeie-a conforme necessário
>> foreach ($impressora in $impressoras) {
>> $novoNomeImpressora = $impressora.Name -replace $parteDoNome, $novoNome
>> Rename-Printer -Name $impressora.Name -NewName $novoNomeImpressora
>> Write-Host "Impressora $($impressora.Name) renomeada para $($novoNomeImpressora)."
>> }
>>
Impressora TECTOY - Q4 renomeada para TESTE - Q4.
PS C:\WINDOWS\system32>,
																														
		

When I use it on my own computer it works fine, but when I take it to a Terminal Server, it returns this:

PS C:\Users\Administrator>

PS C:\Users\Administrator> # Define the part of the name you want to identify on the printer

>> $partofName = "TECTOY"

>>

>> # Set the new name you want to assign to the printers

>> $newName = "TEST"

>>

>> # Get all printers whose names contain the specific part

>> $printers = Get-Printer | Where-Object { $_.Name -like "*$partofName*" }

>>

>> # Cycle through each printer and rename it as needed

>> foreach ($printer in $printers) {

>> $newPrinterName = $printer.Name -replace $partofName, $newName

>> Rename-Printer -Name $printer.Name -NewName $newPrinterName

>> Write-Host "Printer $($printer.Name) renamed to $($newPrinterName)."

>> }

>>

Rename-Printer : Access is denied for the specified resource.

On line:13 character:5

+ Rename-Printer -Name $printer.Name -NewName $newPrinterName ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

    + CategoryInfo : PermissionDenied: (MSFT_Printer:ROOT/StandardCimv2/MSFT_Printer) [Rename-Printer], CimEx

   ception

    + FullyQualifiedErrorId : HRESULT 0x80070005,Rename-Printer

 

TECTOY printer - Q4 (2 redirected) renamed to TEST - Q4 (2 redirected).

Rename-Printer : Access is denied for the specified resource.

On line:13 character:5

+ Rename-Printer -Name $printer.Name -NewName $newPrinterName ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

    + CategoryInfo : PermissionDenied: (MSFT_Printer:ROOT/StandardCimv2/MSFT_Printer) [Rename-Printer], CimEx

   ception

    + FullyQualifiedErrorId : HRESULT 0x80070005,Rename-Printer

 

TECTOY Q4 (Copy 3) printer (2 redirected) renamed to TEST Q4 (Copy 3) (2 redirected).

PS C:\Users\Administrator>

My question would be: it seems to be a denied permission but where do I authorize this issue? it's possible? I really need this function to be able to change her name when she is redirected to the TS.

My question would be: it seems to be a denied permission but where do I authorize this issue? it's possible? I really need this function to be able to change her name when she is redirected to the TS.
Windows Server Printing
Windows Server Printing
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Printing: Printer centralized deployment and management, scan and fax resources management, and document services
688 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ian Xue 37,706 Reputation points Microsoft Vendor
    2024-05-16T04:12:27.9633333+00:00

    Hi Samuel Freitas,

    Thanks for your post.

    Please open the control panel and search for "Devices and Printers". Right-click on the printer and select "Printer Properties", then switch to the Security tab and make sure "Manage this printer" is allowed for your user or group. If the option is greyed out, select "Advanced" and change the owner to the administrator.

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.