Sample script to map additional fields to Universal Print attributes.

%3CLINGO-SUB%20id%3D%22lingo-sub-2670845%22%20slang%3D%22en-US%22%3ESample%20script%20to%20map%20additional%20fields%20to%20Universal%20Print%20attributes.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2670845%22%20slang%3D%22en-US%22%3E%3CP%3EUnfortunately%2C%20the%20Universal%20Print%20Connector%20doesn't%20upload%20fields%20from%20the%20on-premises%20object%2C%20such%20as%20location%20and%20comments.%20Likely%20this%20is%20because%20%22location%22%20is%20now%20represented%20as%20a%20dozen%20attributes%20in%20Azure.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAt%20some%20point%2C%20someone%20should%20look%20all%20this%20detail%20up%20and%20populate%20the%20attributes%20properly%2C%20but%20it%20won't%20be%20me%20and%20it%20won't%20be%20today.%20%3A)%3C%2Fimg%3E%20For%20now%2C%20I%20chose%20to%20map%20the%20fields%20as%20follows%2C%20but%20you%20can%20obviously%20adjust%20this%20as%20necessary%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eon-prem%20%22Location%22%20%3D%20cloud%20%22Site%22%3C%2FP%3E%3CP%3Eon-prem%20%22Comment%22%20%3D%20cloud%20%22Room%20Description%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20work%20around%20this%2C%20I%20wrote%20up%20this%20simple%20script%2C%20which%20might%20be%20helpful%20to%20others.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENOTE%3A%20There%20are%20several%20ways%20to%20do%20this%2C%20but%20I%20like%20the%3CA%20href%3D%22https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FJoin-Object%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20join-object%3C%2FA%3E%20cmdlet%2C%20so%20be%20sure%20to%20install%20that%20first.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EInstall-Module%20UniversalPrintManagement%0AInstall-Module%20join-object%20%0A%0A%23Run%20from%20the%20print%20server%3A%0A%0A%24OnPremPrinters%20%3D%20Get-Printer%20%0A%0AConnect-UPService%20%0A%0A%24CloudPrinters%20%3D%20Get-UPPrinter%0A%0A%24Merge%20%3D%20Join-Object%20-Left%20%24OnPremPrinters%20-LeftJoinProperty%20Name%20-Right%20%24CloudPrinters%20-RightJoinProperty%20name%20-Prefix%20Cloud_%0A%0Aforeach%20(%24printer%20in%20%24Merge)%20%7B%0A%20%20%20%20Set-UPPrinterProperty%20-PrinterId%20%24printer.Cloud_PrinterId%20-Site%20%24printer.Location%20-RoomDescription%20%24printer.Comment%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Untitled.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F304800iA18FC200AB469484%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Untitled.png%22%20alt%3D%22Untitled.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Unfortunately, the Universal Print Connector doesn't upload fields from the on-premises object, such as location and comments. Likely this is because "location" is now represented as a dozen attributes in Azure.

 

At some point, someone should look all this detail up and populate the attributes properly, but it won't be me and it won't be today. :) For now, I chose to map the fields as follows, but you can obviously adjust this as necessary:

 

on-prem "Location" = cloud "Site"

on-prem "Comment" = cloud "Room Description"

 

To work around this, I wrote up this simple script, which might be helpful to others.

 

NOTE: There are several ways to do this, but I like the join-object cmdlet, so be sure to install that first.

 

 

 

 

 

Install-Module UniversalPrintManagement
Install-Module join-object 

#Run from the print server:

$OnPremPrinters = Get-Printer 

Connect-UPService 

$CloudPrinters = Get-UPPrinter

$Merge = Join-Object -Left $OnPremPrinters -LeftJoinProperty Name -Right $CloudPrinters -RightJoinProperty name -Prefix Cloud_

foreach ($printer in $Merge) {
    Set-UPPrinterProperty -PrinterId $printer.Cloud_PrinterId -Site $printer.Location -RoomDescription $printer.Comment
}

 

Untitled.png

0 Replies