SOLVED

UPrint get ShareId in printer properties from Powershell

Copper Contributor

Hey there, I'm trying to apply permissions to 100 shared printers with Powershell but the none of the commands in the current module seem to have the ability to grab a shared printer's ShareId which is a requirement of the Grant-UPAccess command. I have to look them up tediously one by one in the portal and I may as well just add the groups by hand while I'm there if I'm doing that. Am I missing something or is that something coming in the future to the module perhaps? 

 

Thanks

9 Replies

@NerradPB Have you looked at the PowerShell documentation here - https://docs.microsoft.com/en-us/universal-print/fundamentals/universal-print-powershell?

 

You can get the same by trying the following sequence of commands:

> Connect-UPService

> $printers = Get-UPPrinter

> $printers[0].Share | Format-list

 

Hope this helps!

 

Thanks

Saurabh

 

@Saurabh_Bansal

 

Hi thanks for the reply, yes I've read through the documentation several times. Unless I'm really blind today (and often I am), Get-UpPrinter does not reveal the ShareId anywhere near as I can tell. It tells you IF it's shared, and what the share name is, but that's all. 

That command doesn't seem to do anything for me. Returned no results.

 

 

@NerradPB Get-UPprinter returns "printers" object as a collection. Within the printer object, you will have "share" as object collection. Share object has ShareId, ShareName and CreatedDateTime as its properties.

 

Have you implemented all three commands in PowerShell that I listed above to see if it returns the ShareID?

> $printers = Get-UPPrinter

> $printers[0].Share[0].ShareID

 

Thanks,

Saurabh

 

@Saurabh_Bansal 

 

Yes, as I mentioned in the previous reply. 

 

"That command doesn't seem to do anything for me. Returned no results."

@NerradPB - the only reason I see that happening is when the printer is not shared. When you Get-UPPrinter, what does it say against printer's "IsShared" and "Share" properties?

 

Here is the output from what I run:

 > $myprinter = Get-UPPrinter | where-object {$_.Name -eq "printer_shared"}

> $myprinter |Format-List

 

PrinterId : f10a7a74-a2a0-421a-97ff-258a68979d83
Name : printer_shared
Manufacturer : Test
Model : Test
RegisteredBy :
RegisteredDateTime : 8/28/2020 7:03:05 PM +00:00
Status : Microsoft.UPManagement.Models.PrinterStatus
Capabilities :
IsShared : True
Location : Microsoft.UPManagement.Models.PrinterLocation
Jobs :
Share : Microsoft.UPManagement.Models.PrinterShare
Connectors : {}

>

 

If I run it for a printer that is not shared, here is what I get:

> $myprinter1 = Get-UPPrinter | where-object {$_.Name -eq "printer_not_shared"}

> $myprinter1 |Format-List

 

PrinterId : 5aa18aaa-93f7-4884-8919-c8ccded505ff
Name : printer_not_shared
Manufacturer : Test
Model : Test
RegisteredBy :
RegisteredDateTime : 8/28/2020 10:05:00 PM +00:00
Status : Microsoft.UPManagement.Models.PrinterStatus
Capabilities :
IsShared : False
Location : Microsoft.UPManagement.Models.PrinterLocation
Jobs :
Share :
Connectors : {}

>

 

If you continue to face issues, I recommend reaching out to Support via https://portal.azure.com/#blade/Microsoft_Azure_Support/HelpAndSupportBlade/newsupportrequest 

 

@Saurabh_Bansal 

 Hi, Yes I can get all of that information when I run get-upprinter but the output you're showing me isn't from the same script that you posted in your first reply. 

 

In any case, none of that gives you the ShareID property, which is required to apply permissions using the grant-upaccess command

NerradPB_0-1598886438544.png

NerradPB_1-1598886657167.png

 

best response confirmed by Saurabh_Bansal (Microsoft)
Solution

@NerradPB 

 

I can get the shareID like this:

 

Get-UPPrinter | select -ExpandProperty share | select sharename,shareid

 

Then I can share like this:

 

Grant-UPAccess -GroupId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx-ShareID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx

 

@KurtJc 

Thanks mang, that worked a treat. I don't recall that option being available in the previous module update but I may have missed it. Cheers! 

 

1 best response

Accepted Solutions
best response confirmed by Saurabh_Bansal (Microsoft)
Solution

@NerradPB 

 

I can get the shareID like this:

 

Get-UPPrinter | select -ExpandProperty share | select sharename,shareid

 

Then I can share like this:

 

Grant-UPAccess -GroupId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx-ShareID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx

 

View solution in original post