How to Automate Google Cloud Print Printer Sharing

KB Home   |   How to Automate Google Cloud Print Printer Sharing

Main.HowToAutomateGCPPrinterSharing History

Hide minor edits - Show changes to output

November 22, 2019, at 03:20 AM by Mel Zouzoulas -
Changed line 48 from:
Check out [[https://www.papercut.com/products/free-software/mobility-print/|PaperCut Mobility Print]] which is an easy way to print from your iOS, Android, `ChromeOS, Windows and `MacOS. You can learn more about it [[https://www.papercut.com/products/free-software/mobility-print/|here]]
to:
Check out [[https://www.papercut.com/products/free-software/mobility-print/|PaperCut Mobility Print]] which is an easy way to print from your iOS, Android, `ChromeOS, Windows and `MacOS. You can learn more about migrating from GCP to Mobility Print over [[https://www.papercut.com/kb/Main/HowToMigrateFromGoogleCloudPrintToMobilityPrint|here]]
November 22, 2019, at 03:19 AM by Mel Zouzoulas - Added Mobility Print
Added lines 46-48:

!!Looking for an alternative to GCP?
Check out [[https://www.papercut.com/products/free-software/mobility-print/|PaperCut Mobility Print]] which is an easy way to print from your iOS, Android, `ChromeOS, Windows and `MacOS. You can learn more about it [[https://www.papercut.com/products/free-software/mobility-print/|here]]
January 19, 2018, at 09:37 PM by Arturo A - i made this
January 19, 2018, at 09:35 PM by Arturo A - i made this
Changed line 1 from:
(:title How to Automate Google Cloud Print Printer Sharing  Title:)
to:
(:title How to Automate Google Cloud Print Printer Sharing  :)
Changed line 1 from:
(:title How to Automate GCP Printer Sharing  Title:)
to:
(:title How to Automate Google Cloud Print Printer Sharing  Title:)
Changed lines 3-4 from:
Up until recently the only automated task in our [[Google Cloud Print integration| https://www.papercut.com/products/ng/manual/applicationserver/topics/mobile-google-cloud-print.html]] was PaperCut's publishing of the printers to GCP. Admins would then have to manually share many tens or hundreds of GCP printers to many hundreds or thousands of users. Even if an admin distills the cohorts of students, faculty, and staff to a relative few groups within one's G Suite domain group list, this is still a huge drag. However, we have invested some effort in working out the steps to automate the sharing of GCP printers, and I will describe that here:
to:
Up until recently the only automated task in our [[https://www.papercut.com/products/ng/manual/applicationserver/topics/mobile-google-cloud-print.html|Google Cloud Print integration]] was PaperCut's publishing of the printers to GCP. Admins would then have to manually share many tens or hundreds of GCP printers to many hundreds or thousands of users. Even if an admin distills the cohorts of students, faculty, and staff to a relative few groups within one's G Suite domain group list, this is still a huge drag. However, we have invested some effort in working out the steps to automate the sharing of GCP printers, and I will describe that here:
Changed lines 6-7 from:
Automating the sharing and management of Google Cloud Print printers requires setting yourself up with the open source command line tool, Google Apps Manager. GAM requires that you authenticate it with one of your domain's Super Admin accounts. The setup process will also initialize a personalized instance of GAM on Google Cloud Platform. The free license of Google Cloud Platform should support the GAM needs of most organizations. A subscription to Google Cloud Platform is not required. The GitHub wiki has simple instructions for downloading, installing and starting to use GAM here: https://github.com/jay0lee/GAM/wiki.
to:
Automating the sharing and management of Google Cloud Print printers requires setting yourself up with the open source command line tool, Google Apps Manager. GAM requires that you authenticate it with one of your domain's Super Admin accounts. The setup process will also initialize a personalized instance of GAM on Google Cloud Platform. The free license of Google Cloud Platform should support the GAM needs of most organizations. A subscription to Google Cloud Platform is not required. GAM's Git Hub wiki has simple instructions for downloading, installing and starting to use it here: https://github.com/jay0lee/GAM/wiki.
Changed line 15 from:
!!Creating the script that will automate sharing
to:
!!Creating the commands that will automate sharing
Changed lines 18-19 from:
 
to:
Attach:inline1796834495.png
Changed lines 21-25 from:
Below is the formula that will list all possible command combinations of each id and user group. Copy and paste it into cell A2. I will include it in a text file attachment in case our ticketing system does anything weird to it.
=IF(ROW()
-ROW($A$2)+1>COUNTA($C$2:$C$9)*COUNTA($B$2:$B$8),"",INDEX(" ./gam printer "&$C$2:$C$9,INT((ROW()-ROW($A$2))/COUNTA($B$2:$B$8)+1))&INDEX(" add user "&$B$2:$B$8,MOD(ROW()-ROW($A$2),COUNTA($B$2:$B$8))+1))
Formula
notes:
$B$2:$B$8 are the email column values, and $C$2:$C$9 are the printer ID list values. $A$2 references the cell the formula went into. These cell references can be customized based on your need.
The text string element " ./gam printer " assumes you will be running the script from macOS (like me) or Linux but in all likelihood, you will execute from Windows, so remove the leading dot and slash as necessary.
to:


Below is the formula that will list all possible command combinations of each printer ID and user group. Copy and paste it into cell A2.

->@@=IF(ROW()-ROW($A$2)+1>COUNTA($C$2:$C$9)*COUNTA($B$2:$B$8),"",INDEX(" ./gam printer "&$C$2:$C$9,INT((ROW()-ROW($A$2))/COUNTA($B$2:$B$8)+1))&INDEX(" add user "&$B$2:$B$8,MOD(ROW()-ROW($A$2),COUNTA($B$2:$B$8))+1))@@

!!!Formula
notes:
@@$B$2:$B$8@@ are the email column values, and @@$C$2:$C$9@@ are the printer ID list values. @@$A$2@@ references the cell the formula went into. These cell references can be customized based on your need. The text string element @@" ./gam printer "@@ assumes you will be running the script from macOS (like me) or Linux but in all likelihood, you will execute from Windows, so remove the leading dot and slash as necessary.
Changed lines 31-39 from:
 
Then, copy and paste cells A2 through the end of
the column into a new Notepad text file. Save it as printers.cmd, and save it into your GAM directory.
Next, run the CMD file as a local administrator by right clicking and hitting "Run as administrator." Depending on the number of printers and groups, this may take a while.
Sharing this way will not send users a printer sharing notification, they will just appear on their list of available printers.


!!Subheading

to:
Attach:inline-2141268622.png

!!Creating and executing your script
Then, copy and paste cells A2 through
the end of the column into a new text file.
!!!In Windows:
Save it as @@printers.cmd@@, and save it into your GAM directory.
Next, run the CMD file as a local administrator by right clicking and hitting "Run as administrator."
!!!In macOS and Linux:
Save it as @@printers@@,
and save it into your GAM directory.
Next, launch terminal and CD to your GAM directory. Use @@chmod@@ to make @@printers@@ executable by you then run it as @@./printers@@.

Depending on the number of printers and groups, this may take a while. Sharing this way will not send users a printer sharing notification, they will just appear on their list of available printers.


See? Automation
!

Changed line 49 from:
''Categories:'' [[Category.TODOFirstCategory|+]], [[Category.TODOSecondCategoryIfNeeded|+]]
to:
''Categories:'' [[Category.Printers|+]], [[Category.GoogleCloudPrint|+]]
Changed line 51 from:
[-Keywords: TODO keywords here if needed-]
to:
[-Keywords: Google Cloud Print, Google Cloud Platform, GAM, sharing printers, automation, scripts, spreadsheets, formulas, concatenation-]
Added lines 1-38:
(:title How to Automate GCP Printer Sharing  Title:)

Up until recently the only automated task in our [[Google Cloud Print integration| https://www.papercut.com/products/ng/manual/applicationserver/topics/mobile-google-cloud-print.html]] was PaperCut's publishing of the printers to GCP. Admins would then have to manually share many tens or hundreds of GCP printers to many hundreds or thousands of users. Even if an admin distills the cohorts of students, faculty, and staff to a relative few groups within one's G Suite domain group list, this is still a huge drag. However, we have invested some effort in working out the steps to automate the sharing of GCP printers, and I will describe that here:

!!Got GAM?
Automating the sharing and management of Google Cloud Print printers requires setting yourself up with the open source command line tool, Google Apps Manager. GAM requires that you authenticate it with one of your domain's Super Admin accounts. The setup process will also initialize a personalized instance of GAM on Google Cloud Platform. The free license of Google Cloud Platform should support the GAM needs of most organizations. A subscription to Google Cloud Platform is not required. The GitHub wiki has simple instructions for downloading, installing and starting to use GAM here: https://github.com/jay0lee/GAM/wiki.

!!Collect your domain's groups and printers
Once your GAM project is up and running, the next step in the printer sharing automation process is to collect your organization's list of groups and printer IDs since those are the attributes the command to share a printer requires.
->This command writes to a CSV file the list of printers owned or accessible by the user GAM is running as:
->@@gam print printers > printer_properties.csv@@
->This command writes to a CSV file all the groups in the domain:
->@@gam print groups > groups.csv@@

!!Creating the script that will automate sharing
Next, open a new spreadsheet document in either Excel or Google Sheets and call it "Commands." Open @@groups.csv@@ and copy the emails column to Commands sheet's column B. Then, open @@printer_properties.csv@@ and copy the ID column to Commands sheet's column C.
This should be close to what you have now:
 
The Commands sheet's column A should still be blank because this is the column our formula will populate with all of the commands required to share every printer with every group.
Below is the formula that will list all possible command combinations of each id and user group. Copy and paste it into cell A2. I will include it in a text file attachment in case our ticketing system does anything weird to it.
=IF(ROW()-ROW($A$2)+1>COUNTA($C$2:$C$9)*COUNTA($B$2:$B$8),"",INDEX(" ./gam printer "&$C$2:$C$9,INT((ROW()-ROW($A$2))/COUNTA($B$2:$B$8)+1))&INDEX(" add user "&$B$2:$B$8,MOD(ROW()-ROW($A$2),COUNTA($B$2:$B$8))+1))
Formula notes:
$B$2:$B$8 are the email column values, and $C$2:$C$9 are the printer ID list values. $A$2 references the cell the formula went into. These cell references can be customized based on your need.
The text string element " ./gam printer " assumes you will be running the script from macOS (like me) or Linux but in all likelihood, you will execute from Windows, so remove the leading dot and slash as necessary.
Next, select and copy cell A2 and paste the formula into the rows below. All possible printer and email command combinations will be listed based on the two list values, like so:
 
Then, copy and paste cells A2 through the end of the column into a new Notepad text file. Save it as printers.cmd, and save it into your GAM directory.
Next, run the CMD file as a local administrator by right clicking and hitting "Run as administrator." Depending on the number of printers and groups, this may take a while.
Sharing this way will not send users a printer sharing notification, they will just appear on their list of available printers.


!!Subheading


----
''Categories:'' [[Category.TODOFirstCategory|+]], [[Category.TODOSecondCategoryIfNeeded|+]]
----
[-Keywords: TODO keywords here if needed-]

Comments

Share your findings and experience with other PaperCut users. Feel free to add comments and suggestions about this Knowledge Base article. Please don't use this for support requests.

Article last modified on November 22, 2019, at 03:20 AM
Printable View   |   Article History   |   Edit Article