# Collections of ChromeOS Devices - [Python Regular Expressions](Python-Regular-Expressions) Search function - [Definitions](#definitions) - [Organization Unit Quoting](#organization-unit-quoting) - [Query Quoting](#query-quoting) - [Query Notes](#query-notes) - [CrOS Type Entity](#cros-type-entity) - [All ChromeOS devices](#all-chromeos-devices) - [A list of ChromeOS deviceIds](#a-list-of-chromeos-deviceids) - [A list of ChromeOS device serial numbers](#a-list-of-chromeos-device-serial-numbers) - [ChromeOS devices directly in the Organization Unit ``](#chromeos-devices-directly-in-the-organization-unit-orgunititem) - [ChromeOS devices in the Organization Unit `` and all of its sub Organization Units](#chromeos-devices-in-the-organization-unit-orgunititem-and-all-of-its-sub-organization-units) - [ChromeOS devices directly in the Organization Units ``](#chromeos-devices-directly-in-the-organization-units-orgunitlist) - [ChromeOS devices in the Organization Units `` and all of their sub Organization Units](#chromeos-devices-in-the-organization-units-orgunitlist-and-all-of-their-sub-organization-units) - [ChromeOS devices directly in the Organization Unit `` that also match a query](#chromeos-devices-directly-in-the-organization-unit-orgunititem-that-also-match-a-query) - [ChromeOS devices in the Organization Unit `` and all of its sub Organization Units that also match a query](#chromeos-devices-in-the-organization-unit-orgunititem-and-all-of-its-sub-organization-units-that-also-match-a-query) - [ChromeOS devices directly in the Organization Units `` that also match a query](#chromeos-devices-directly-in-the-organization-units-orgunitlist-that-also-match-a-query) - [ChromeOS devices in the Organization Units `` and all of their sub Organization Units that also match a query](#chromeos-devices-in-the-organization-units-orgunitlist-and-all-of-their-sub-organization-units-that-also-match-a-query) - [ChromeOS devices directly in the Organization Unit `` that also match any query in a list of queries](#chromeos-devices-directly-in-the-organization-unit-orgunititem-that-also-match-any-query-in-a-list-of-queries) - [ChromeOS devices in the Organization Unit `` and all of its sub Organization Units that also match any query in a list of queries](#chromeos-devices-in-the-organization-unit-orgunititem-and-all-of-its-sub-organization-units-that-also-match-any-query-in-a-list-of-queries) - [ChromeOS devices directly in the Organization Units `` that also match any query in a list of queries](#chromeos-devices-directly-in-the-organization-units-orgunitlist-that-also-match-any-query-in-a-list-of-queries) - [ChromeOS devices in the Organization Units `` and all of their sub Organization Units that also match any query in a list of queries](#chromeos-devices-in-the-organization-units-orgunitlist-and-all-of-their-sub-organization-units-that-also-match-any-query-in-a-list-of-queries) - [ChromeOS devices that match a query](#chromeos-devices-that-match-a-query) - [ChromeOS devices that match any query in a list of queries](#chromeos-devices-that-match-any-query-in-a-list-of-queries) - [ChromeOS deviceIds in a flat file/Google Doc/Google Cloud Storage Object](#chromeos-deviceids-in-a-flat-filegoogle-docgoogle-cloud-storage-object) - [ChromeOS serial numbers in a flat file/Google Doc/Google Cloud Storage Object](#chromeos-serial-numbers-in-a-flat-filegoogle-docgoogle-cloud-storage-object) - [Selected ChromeOS deviceIds in a CSV file/Google Sheet/Google Doc/Google Cloud Storage Object](#selected-chromeos-deviceids-in-a-csv-filegoogle-sheetgoogle-docgoogle-cloud-storage-object) - [Selected ChromeOS serial numbers in a CSV file/Google Sheet/Google Doc/Google Cloud Storage Object](#selected-chromeos-serial-numbers-in-a-csv-filegoogle-sheetgoogle-docgoogle-cloud-storage-object) - [ChromeOS devices from OUs in a flat file/Google Doc/Google Cloud Storage Object](#chromeos-devices-from-ous-in-a-flat-filegoogle-docgoogle-cloud-storage-object) - [ChromeOS deviceIds from OUs in a CSV file/Google Sheet/Google Doc/Google Cloud Storage Object](#chromeos-deviceids-from-ous-in-a-csv-filegoogle-sheetgoogle-docgoogle-cloud-storage-object) - [ChromeOS devices directly in or from OUs in a CSV file/Google Sheet/Google Doc/Google Cloud Storage Object](#chromeos-devices-directly-in-or-from-ous-in-a-csv-filegoogle-sheetgoogle-docgoogle-cloud-storage-object) - [ChromeOS deviceIds from data fields identified in a `csvkmd` argument](#chromeos-deviceids-from-data-fields-identified-in-a-csvkmd-argument) - [Examples using CSV files](#examples-using-csv-files) - [Examples using multiple queries or Org Units](#examples-using-multiple-queries-or-org-units) ## Definitions * [Basic Items](Basic-Items) * [List Items](List-Items) * [Command data from Google Docs/Sheets/Storage](Command-Data-From-Google-Docs-Sheets-Storage) ``` ::= ::= ::= https://storage.cloud.google.com//| https://storage.googleapis.com//| gs:///| / ::= ||( ) ::= |id: ::= ||( ) ::= (json [charset ] ) | (json file [charset ]) | ``` ``` ::= (all cros)| (cros )| (cros_sn )| (cros_ou )| (cros_ou_and_children )| (cros_ous )| (cros_ous_and_children )| (cros_ou_query )| (cros_ou_and_children_query )| (cros_ous_query )| (cros_ous_and_children_query )| (cros_ou_queries )| (cros_ou_and_children_queries )| (cros_ous_queries )| (cros_ous_and_children_queries )| (crosquery )| (crosqueries )| (crosfile (( [charset ])| (gdoc )| (gcsdoc )) [delimiter ])| (crosfile_sn (( [charset ])| (gdoc )| (gcsdoc )) [delimiter ])| (croscsvfile (((:)+ [charset ] )| (gsheet(:)+ )| (gdoc(:)+ )| (gcscsv(:)+ )| (gcsdoc(:)+ )) [warnifnodata] [columndelimiter ] [noescapechar ] [quotechar ] [endcsv|(fields )] (matchfield|skipfield )* [delimiter ])| (croscsvfile_sn (((:)+ [charset ] )| (gsheet(:)+ )| (gdoc(:)+ )| (gcscsv(:)+ )| (gcsdoc(:)+ )) [warnifnodata] [columndelimiter ] [noescapechar ] [quotechar ] [endcsv|(fields )] (matchfield|skipfield )* [delimiter ])| (datafile cros|cros_sn|cros_ous|cros_ous_and_children (( [charset ])| (gdoc )| (gcsdoc )) [delimiter ])| (csvdatafile cros|cros_sn|cros_ous|cros_ous_and_children (((:)+ [charset ] )| (gsheet(:)+ )| (gdoc(:)+ )| (gcscsv(:)+ )| (gcsdoc(:)+ )) [warnifnodata] [columndelimiter ] [noescapechar ] [quotechar ] [endcsv|(fields )] (matchfield|skipfield )* [delimiter ])| (csvkmd cros|cros_sn|cros_ous|cros_ous_and_children ((| (gsheet )| (gdoc )| (gcscsv )| (gcsdoc )) [charset ] [columndelimiter ] [noescapechar ] [quotechar ] [fields ]) keyfield [keypattern ] [keyvalue ] [delimiter ] subkeyfield [keypattern ] [keyvalue ] [delimiter ] (matchfield|skipfield )* [datafield (:)* [delimiter ]]) (croscsvdata (:*)) ``` ## Organization Unit Quoting * `` should be enclosed in `"` if it contains a space, comma or single quote. * `` may require special quoting based on whether the OUs contain spaces, commas or single quotes. For quoting rules, see: [List Quoting Rules](Command-Line-Parsing) ## Query Quoting `` may require special quoting based on whether the queries contain spaces, commas or single quotes. For quoting rules, see: [List Quoting Rules](Command-Line-Parsing) ## Query Notes See https://support.google.com/chrome/a/answer/1698333 Undocumented API query terms. ``` ::= YYYY-MM-DD # Specific date ..YYYY-MM-DD # Before a date YYYY-MM-DD.. # After a date YYYY-MM-DD..YYYY-MM-DD # Range of dates aue: compliance:compliant|pending_update|not_compliant last_user_activity: policy_status:true|false public_model_name: update_status:default_os_up_to_date|pending_update|os_image_download_not_started|os_image_download_in_progress|os_update_need_reboot ``` ## CrOS Type Entity Use these options to select Chrome OS devices for GAM commands. ## All ChromeOS devices * `all cros` ## A list of ChromeOS deviceIds * `cros ` ## A list of ChromeOS device serial numbers * `cros_sn ` ## ChromeOS devices directly in the Organization Unit `` * `cros_ou ` ## ChromeOS devices in the Organization Unit `` and all of its sub Organization Units * `cros_ou_and_children ` ## ChromeOS devices directly in the Organization Units `` * `cros_ous ` ## ChromeOS devices in the Organization Units `` and all of their sub Organization Units * `cros_ous_and_children ` ## ChromeOS devices directly in the Organization Unit `` that also match a query * `cros_ou_query ` ## ChromeOS devices in the Organization Unit `` and all of its sub Organization Units that also match a query * `cros_ou_and_children_query ` ## ChromeOS devices directly in the Organization Units `` that also match a query * `cros_ous_query ` ## ChromeOS devices in the Organization Units `` and all of their sub Organization Units that also match a query * `cros_ous_and_children_query ` ## ChromeOS devices directly in the Organization Unit `` that also match any query in a list of queries * `cros_ou_queries ` ## ChromeOS devices in the Organization Unit `` and all of its sub Organization Units that also match any query in a list of queries * `cros_ou_and_children_queries ` ## ChromeOS devices directly in the Organization Units `` that also match any query in a list of queries * `cros_ous_queries ` ## ChromeOS devices in the Organization Units `` and all of their sub Organization Units that also match any query in a list of queries * `cros_ous_and_children_queries ` ## ChromeOS devices that match a query * `crosquery ` ## ChromeOS devices that match any query in a list of queries * `crosqueries ` ## ChromeOS deviceIds in a flat file/Google Doc/Google Cloud Storage Object ``` crosfile (( [charset ])| (gdoc )| (gcsdoc )) [delimiter ] ``` * `` - A flat file containing a single ChromeOS deviceId per row * `charset ` - The character aset of the file if it isn't UTF-8 * `gdoc ` - A Google Doc containing a single ChromeOS deviceId per row * `gcsdoc ` - A Google Cloud Storage Bucket Object containing a single ChromeOS deviceId per row * `delimiter ` - There are multiple deviceIds per row separated by ``; if not specified, there is single deviceId per row ## ChromeOS serial numbers in a flat file/Google Doc/Google Cloud Storage Object ``` crosfile_sn (( [charset ])| (gdoc )| (gcsdoc )) [delimiter ] ``` * `` - A flat file containing a single ChromeOS serial number per row * `charset ` - The character aset of the file if it isn't UTF-8 * `gdoc ` - A Google Doc containing a single ChromeOS serial number per row * `gcsdoc ` - A Google Cloud Storage Bucket Object containing a single ChromeOS serial number per row * `delimiter ` - There are multiple serial numbers per row separated by ``; if not specified, there is single serial number per row ## Selected ChromeOS deviceIds in a CSV file/Google Sheet/Google Doc/Google Cloud Storage Object ``` croscsvfile (((:)+ [charset ] )| (gsheet(:)+ )| (gdoc(:)+ )| (gcscsv(:)+ )| (gcsdoc(:)+ )) [warnifnodata] [columndelimiter ] [noescapechar ] [quotechar ] [endcsv|(fields )] (matchfield|skipfield )* [delimiter ] ``` * `(:)+` - A CSV file and the one or more columns that contain ChromeOS deviceIds * `charset ` - The character aset of the file if it isn't UTF-8 * `gsheet(:)+ ` - A Google Sheet and the one or more columns that contain ChromeOS deviceIds * `gdoc(:)+ ` - A Google Doc and the one or more columns that contain ChromeOS deviceIds * `gcscsv(:)+ ` - A Google Cloud Storage Bucket Object and the one or more columns that contain ChromeOS deviceIds * `gcsdoc(:)+ ` - A Google Cloud Storage Bucket Object and the one or more columns that contain ChromeOS deviceIds * `warnifnodata` - Issue message 'No CSV file data found' and exit with return code 60 if there is no data selected from the file * `columndelimiter ` - Columns are separated by ``; if not specified, the value of `csv_input_column_delimiter` from `gam.cfg` will be used * `noescapechar ` - Should `\` be ignored as an escape character; if not specified, the value of `csv_input_no_escape_char` from `gam.cfg` will be used * `quotechar ` - The column quote characer is ``; if not specified, the value of `csv_input_quote_char` from `gam.cfg` will be used * `endcsv` - Use this option to signal the end of the csvfile parameters in the case that the next argument on the command line is `fields` but is specifying the output field list for the command not column headings * `fields ` - The column headings of a CSV file that does not contain column headings * `(matchfield|skipfield )*` - The criteria to select rows from the CSV file; can be used multiple times; if not specified, all rows are selected * `delimiter ` - There are multiple deviceIds per column separated by ``; if not specified, there is single deviceId per column ## Selected ChromeOS serial numbers in a CSV file/Google Sheet/Google Doc/Google Cloud Storage Object ``` croscsvfile_sn (((:)+ [charset ] )| (gsheet(:)+ )| (gdoc(:)+ )| (gcscsv(:)+ )| (gcsdoc(:)+ )) [warnifnodata] [columndelimiter ] [noescapechar ] [quotechar ] [endcsv|(fields )] (matchfield|skipfield )* [delimiter ] ``` * `(:)+` - A CSV file and the one or more columns that contain ChromeOS serial numbers * `charset ` - The character aset of the file if it isn't UTF-8 * `gsheet(:)+ ` - A Google Sheet and the one or more columns that contain ChromeOS serial numbers * `gdoc(:)+ ` - A Google Doc and the one or more columns that contain ChromeOS serial numbers * `gcscsv(:)+ ` - A Google Cloud Storage Bucket Object and the one or more columns that contain ChromeOS serial numbers * `gcsdoc(:)+ ` - A Google Cloud Storage Bucket Object and the one or more columns that contain ChromeOS serial numbers * `warnifnodata` - Issue message 'No CSV file data found' and exit with return code 60 if there is no data selected from the file * `columndelimiter ` - Columns are separated by ``; if not specified, the value of `csv_input_column_delimiter` from `gam.cfg` will be used * `noescapechar ` - Should `\` be ignored as an escape character; if not specified, the value of `csv_input_no_escape_char` from `gam.cfg` will be used * `quotechar ` - The column quote characer is ``; if not specified, the value of `csv_input_quote_char` from `gam.cfg` will be used * `endcsv` - Use this option to signal the end of the csvfile parameters in the case that the next argument on the command line is `fields` but is specifying the output field list for the command not column headings * `fields ` - The column headings of a CSV file that does not contain column headings * `(matchfield|skipfield )*` - The criteria to select rows from the CSV file; can be used multiple times; if not specified, all rows are selected * `delimiter ` - There are multiple serial numbers per column separated by ``; if not specified, there is single deviceId per column ## ChromeOS devices from OUs in a flat file/Google Doc/Google Cloud Storage Object ``` datafile cros|cros_sn|cros_ous|cros_ous_and_children (( [charset ])| (gdoc )| (gcsdoc )) [delimiter ] ``` * `cros|cros_sn|cros_ous|cros_ous_and_children` - The type of item in the file * `` - A flat file containing a single item per row * `charset ` - The character aset of the file if it isn't UTF-8 * `gdoc ` - A Google Doc containing a single item per row * `gcsdoc ` - A Google Cloud Storage Bucket Object containing a item per row * `delimiter ` - There are multiple items per row separated by ``; if not specified, there is single item per row ## ChromeOS deviceIds from OUs in a CSV file/Google Sheet/Google Doc/Google Cloud Storage Object ``` csvdatafile cros|cros_sn|cros_sn|cros_ous|cros_ous_and_children (((:)+ [charset ] )| (gsheet(:)+ )| (gdoc(:)+ )| (gcscsv(:)+ )| (gcsdoc(:)+ )) [warnifnodata] [columndelimiter ] [noescapechar ] [quotechar ] [endcsv|(fields )] (matchfield|skipfield )* [delimiter ] ``` * `cros|cros_ous|cros_ous_and_children` - The type of item in the file * `(:)+` - A CSV file and the one or more columns that contain ChromeOS deviceIds * `charset ` - The character aset of the file if it isn't UTF-8 * `gsheet(:)+ ` - A Google Sheet and the one or more columns that contain ChromeOS deviceIds * `gdoc(:)+ ` - A Google Doc and the one or more columns that contain ChromeOS deviceIds * `gcscsv(:)+ ` - A Google Cloud Storage Bucket Object and the one or more columns that contain ChromeOS deviceIds * `gcsdoc(:)+ ` - A Google Cloud Storage Bucket Object and the one or more columns that contain ChromeOS deviceIds * `warnifnodata` - Issue message 'No CSV file data found' and exit with return code 60 if there is no data selected from the file * `columndelimiter ` - Columns are separated by ``; if not specified, the value of `csv_input_column_delimiter` from `gam.cfg` will be used * `noescapechar ` - Should `\` be ignored as an escape character; if not specified, the value of `csv_input_no_escape_char` from `gam.cfg` will be used * `quotechar ` - The column quote characer is ``; if not specified, the value of `csv_input_quote_char` from `gam.cfg` will be used * `endcsv` - Use this option to signal the end of the csvfile parameters in the case that the next argument on the command line is `fields` but is specifying the output field list for the command not column headings * `fields ` - The column headings of a CSV file that does not contain column headings * `(matchfield|skipfield )*` - The criteria to select rows from the CSV file; can be used multiple times; if not specified, all rows are selected * `delimiter ` - There are multiple deviceIds per column separated by ``; if not specified, there is single deviceId per column ## ChromeOS devices directly in or from OUs in a CSV file/Google Sheet/Google Doc/Google Cloud Storage Object ``` csvkmd cros|cros_sn|cros_ous|cros_ous_and_children ((| (gsheet )| (gdoc )| (gcscsv )| (gcsdoc )) [charset ] [columndelimiter ] [noescapechar ] [quotechar ] [fields ]) keyfield [keypattern ] [keyvalue ] [delimiter ] subkeyfield [keypattern ] [keyvalue ] [delimiter ] (matchfield|skipfield )* [datafield (:)* [delimiter ]] ``` * `cros|cros_sn|cros_ous|cros_ous_and_children` - The type of item in the file * `` - A CSV file containing rows with columns of the type of item specified * `charset ` - The character aset of the file if it isn't UTF-8 * `gsheet ` - A Google Sheet containing rows with columns of the type of item specified * `gdoc ` - A Google Doc containing rows with columns of the type of item specified * `warnifnodata` - Issue message 'No CSV file data found' and exit with return code 60 if there is no data selected from the file * `columndelimiter ` - Columns are separated by ``; if not specified, the value of `csv_input_column_delimiter` from `gam.cfg` will be used * `noescapechar ` - Should `\` be ignored as an escape character; if not specified, the value of `csv_input_no_escape_char` from `gam.cfg` will be used * `quotechar ` - The column quote characer is ``; if not specified, the value of `csv_input_quote_char` from `gam.cfg` will be used * `endcsv` - Use this option to signal the end of the csvfile parameters in the case that the next argument on the command line is `fields` but is specifying the output field list for the command not column headings * `fields ` - The column headings of a CSV file that does not contain column headings * `(keyfield [keypattern ] [keyvalue ] [delimiter ])+` * `keyfield ` - The column containing key values * `[keypattern ] [keyvalue ]` - Allows transforming the value(s) in the `keyfield` column. If only `keyvalue ` is specified, all instances of `` in `keyvalue ` will be replaced by the item value. If `keypattern ` is specified, the item value is matched against `` and the matched segments are substituted into `keyvalue ` * `delimiter ` - There are multiple values per keyfield column separated by ``; if not specified, there is single value per keyfield column * `(subkeyfield [keypattern ] [keyvalue ] [delimiter ])*` * `subkeyfield ` - The column containing subkey values * `[keypattern ] [keyvalue ]` - Allows transforming the value(s) in the `subkeyfield` column. If only `keyvalue ` is specified, all instances of `` in `keyvalue ` will be replaced by the item value. If `keypattern ` is specified, the item value is matched against `` and the matched segments are substituted into `keyvalue ` * `delimiter ` - There are multiple values per subkeyfield column separated by ``; if not specified, there is single value per subkeyfield column * `(matchfield|skipfield )*` - The criteria to select rows from the CSV file; can be used multiple times; if not specified, all rows are selected * `(datafield (:])*` * `datafield (:` - There are multiple values per datafield column separated by ``; if not specified, there is single value per datafield column ## ChromeOS deviceIds from data fields identified in a `csvkmd` argument * `croscsvdata (:*)` - Data fields identified in a `csvkmd` argument ## Examples using CSV files You want to print information about ChromeOS devices at your school from Org Units based on graduation year. Example 1 CSV File OrgUnit.csv, exactly the data you want, `keypattern` and `keyvalue` are not required. ``` OrgUnit /Students/2020 /Students/2021 ... ``` For each row, the value from the OrgUnit column is used as the Org Unit name. ``` gam csvkmd cros_ous OrgUnit.csv keyfield OrgUnit print cros ``` Example 2 CSV File GradYear.csv, you have to convert GradYear to Org Unit name `/Students/GradYear`, `keyvalue` is required. ``` GradYear 2020 2021 ... ``` For each row, the value from the GradYear column replaces the keyField name in the `keyvalue` argument and that value is used as the Org Unit name. ``` gam csvkmd cros_ous GradYear.csv keyfield GradYear keyvalue "/Students/GradYear" print cros ``` Example 3 CSV File GradYear.csv, you have to convert GradYear to Org Unit name `/Students/LastTwoDigitsOfGradYear`, `keypattern` and `keyvalue` are required. ``` GradYear 2020 2021 ... ``` For each row, the value from the GradYear column is matched against the `keypattern` and the matched segments are substituted into the `keyvalue` argument and that value is used as the Org Unit name. ``` gam csvkmd cros_ous GradYear.csv keyfield GradYear keypattern '20(..)' keyvalue '/Students/\1' print cros ``` ## Examples using multiple queries or Org Units Example 1 Print information about all ChromeOS devices with a serial number that starts with HY3 or 5CD. ``` gam crosqueries "id:HY3,id:5CD" print cros allfields nolists ``` Example 2 Print information about all ChromeOS devices in two Org Units that contain spaces in their names. ``` gam crosqueries "\"orgUnitPath='/Students/Middle School/2021'\",\"orgUnitPath='/Students/Middle School/2020'\"" print cros allfields nolists ``` This is equivaluent to: ``` gam cros_ous "'/Students/Middle School/2021','/Students/Middle School/2020'" print cros allfields nolists ```