Skip to content

Commit

Permalink
!deploy v2.22.4 with ChromeOSDevice support to resolve #147
Browse files Browse the repository at this point in the history
## 2.22.4

* [Issue #147](#147)
  * Added: `Get-GSChromeOSDevice` - Handles Get or List requests, depending on if you specify a ResourceId or not.
  * Added: `Update-GSChromeOSDevice` - Handles Action, Move and/or Patch requests depending on the parameters passed.
  • Loading branch information
scrthq authored Feb 4, 2019
2 parents 7df207b + a30a78f commit d2507d6
Show file tree
Hide file tree
Showing 8 changed files with 406 additions and 19 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

* [Changelog](#changelog)
* [2.22.4](#2224)
* [2.22.3](#2223)
* [2.22.2](#2222)
* [2.22.1](#2221)
Expand Down Expand Up @@ -72,6 +73,12 @@

***

## 2.22.4

* [Issue #147](https://github.com/scrthq/PSGSuite/issues/147)
* Added: `Get-GSChromeOSDevice` - Handles Get or List requests, depending on if you specify a ResourceId or not.
* Added: `Update-GSChromeOSDevice` - Handles Action, Move and/or Patch requests depending on the parameters passed.

## 2.22.3

* [Issue #144](https://github.com/scrthq/PSGSuite/issues/144)
Expand Down
2 changes: 1 addition & 1 deletion PSGSuite/PSGSuite.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PSGSuite.psm1'

# Version number of this module.
ModuleVersion = '2.22.3'
ModuleVersion = '2.22.4'

# ID used to uniquely identify this module
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'
Expand Down
70 changes: 70 additions & 0 deletions PSGSuite/Private/Move-GSChromeOSDevice.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
function Move-GSChromeOSDevice {
<#
.SYNOPSIS
Moves a ChromeOS device to a new OrgUnit
.DESCRIPTION
Moves a ChromeOS device to a new OrgUnit
.PARAMETER ResourceId
The unique ID of the device you would like to move.
.PARAMETER OrgUnitPath
Full path of the target organizational unit or its ID
.EXAMPLE
Move-GSChromeOSDevice -ResourceId 'AFiQxQ8Qgd-rouSmcd2UnuvhYV__WXdacTgJhPEA1QoQJrK1hYbKJXm-8JFlhZOjBF4aVbhleS2FVQk5lI069K2GULpteTlLVpKLJFSLSL' -OrgUnitPath '/Corp'
Moves the ChromeOS device specified to the /Corp OrgUnit
#>
[OutputType('Google.Apis.Admin.Directory.directory_v1.Data.ChromeOSDevice')]
[cmdletbinding()]
Param
(
[parameter(Mandatory = $true,Position = 0,ValueFromPipelineByPropertyName = $true)]
[Alias('Id','Device','DeviceId')]
[String[]]
$ResourceId,
[parameter(Mandatory = $true,Position = 1)]
[String]
$OrgUnitPath
)
Begin {
$serviceParams = @{
Scope = 'https://www.googleapis.com/auth/admin.directory.device.chromeos'
ServiceType = 'Google.Apis.Admin.Directory.directory_v1.DirectoryService'
}
$service = New-GoogleService @serviceParams -Verbose:$false
$customerId = if ($Script:PSGSuite.CustomerID) {
$Script:PSGSuite.CustomerID
}
else {
"my_customer"
}
$toMove = New-Object 'System.Collections.Generic.List[string]'
}
Process {
$ResourceId | ForEach-Object {
$toMove.Add($_)
}
}
End {
try {
Write-Verbose "Moving the following Chrome OS Devices to OrgUnitPath '$OrgUnitPath':`n - $($toMove -join "`n - ")"
$body = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.ChromeOsMoveDevicesToOu' -Property @{
DeviceIds = $toMove
}
$request = $service.Chromeosdevices.MoveDevicesToOu($body,$customerId,$OrgUnitPath)
$request.Execute()
Write-Verbose "The Chrome OS devices were successfully moved."
}
catch {
if ($ErrorActionPreference -eq 'Stop') {
$PSCmdlet.ThrowTerminatingError($_)
}
else {
Write-Error $_
}
}
}
}
166 changes: 166 additions & 0 deletions PSGSuite/Public/Security/Get-GSChromeOSDevice.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
function Get-GSChromeOSDevice {
<#
.SYNOPSIS
Gets the list of Chrome OS Devices registered for the user's account
.DESCRIPTION
Gets the list of Chrome OS Devices registered for the user's account
.PARAMETER ResourceId
Immutable ID of Chrome OS Device. Gets the list of Chrome OS devices if excluded.
.PARAMETER OrgUnitPath
The full path of the organizational unit or its unique ID.
.PARAMETER Filter
Search string in the format given at: http://support.google.com/chromeos/a/bin/answer.py?answer=1698333
.PARAMETER Projection
Restrict information returned to a set of selected fields.
Acceptable values are:
* "BASIC": Includes only the basic metadata fields (e.g., deviceId, model, status, type, and status)
* "FULL": Includes all metadata fields
Defauls to "FULL"
.PARAMETER PageSize
Page size of the result set
.PARAMETER OrderBy
Device property to use for sorting results.
Acceptable values are:
* "annotatedLocation": Chrome device location as annotated by the administrator.
* "annotatedUser": Chrome device user as annotated by the administrator.
* "lastSync": The date and time the Chrome device was last synchronized with the policy settings in the Admin console.
* "notes": Chrome device notes as annotated by the administrator.
* "serialNumber": The Chrome device serial number entered when the device was enabled.
* "status": Chrome device status. For more information, see the chromeosdevices resource.
* "supportEndDate": Chrome device support end date. This is applicable only for devices purchased directly from Google.
.PARAMETER SortOrder
Whether to return results in ascending or descending order. Must be used with the OrderBy parameter.
Acceptable values are:
* "ASCENDING": Ascending order.
* "DESCENDING": Descending order.
.EXAMPLE
Get-GSChromeOSDevice
Gets the Chrome OS Device list for the customer
#>
[OutputType('Google.Apis.Admin.Directory.directory_v1.Data.ChromeOSDevice')]
[cmdletbinding(DefaultParameterSetName = "List")]
Param
(
[parameter(Mandatory = $false,Position = 0,ValueFromPipeline = $true,ValueFromPipelineByPropertyName = $true,ParameterSetName = "Get")]
[Alias('Id','Device','DeviceId')]
[String[]]
$ResourceId,
[parameter(Mandatory = $false,ParameterSetName = "List")]
[Alias('Query')]
[String]
$Filter,
[parameter(Mandatory = $false,ParameterSetName = "List")]
[String]
$OrgUnitPath,
[parameter(Mandatory = $false)]
[ValidateSet("BASIC","FULL")]
[String]
$Projection = "FULL",
[parameter(Mandatory = $false,ParameterSetName = "List")]
[ValidateRange(1,100)]
[Alias('MaxResults')]
[Int]
$PageSize = "100",
[parameter(Mandatory = $false,ParameterSetName = "List")]
[ValidateSet("annotatedLocation","annotatedUser","lastSync","notes","serialNumber","status","supportEndDate")]
[String]
$OrderBy,
[parameter(Mandatory = $false,ParameterSetName = "List")]
[ValidateSet("ASCENDING","DESCENDING")]
[String]
$SortOrder
)
Begin {
$serviceParams = @{
Scope = 'https://www.googleapis.com/auth/admin.directory.device.chromeos'
ServiceType = 'Google.Apis.Admin.Directory.directory_v1.DirectoryService'
}
$service = New-GoogleService @serviceParams
$customerId = if ($Script:PSGSuite.CustomerID) {
$Script:PSGSuite.CustomerID
}
else {
"my_customer"
}

}
Process {
try {
switch ($PSCmdlet.ParameterSetName) {
Get {
foreach ($dev in $ResourceId) {
try {
Write-Verbose "Getting Chrome OS Device '$dev'"
$request = $service.Chromeosdevices.Get($customerId,$dev)
$request.Execute()
}
catch {
if ($ErrorActionPreference -eq 'Stop') {
$PSCmdlet.ThrowTerminatingError($_)
}
else {
Write-Error $_
}
}
}
}
List {
$request = $service.Chromeosdevices.List($customerId)
if ($PSBoundParameters.Keys -contains 'Filter') {
Write-Verbose "Getting Chrome OS Device list for filter '$Filter'"
$request.Query = $PSBoundParameters['Filter']
}
else {
Write-Verbose "Getting Chrome OS Device list"
}
foreach ($key in $PSBoundParameters.Keys | Where-Object {$_ -ne 'Filter'}) {
switch ($key) {
PageSize {
$request.MaxResults = $PSBoundParameters[$key]
}
default {
if ($request.PSObject.Properties.Name -contains $key) {
$request.$key = $PSBoundParameters[$key]
}
}
}
}
[int]$i = 1
do {
$result = $request.Execute()
$result.Chromeosdevices
if ($result.NextPageToken) {
$request.PageToken = $result.NextPageToken
}
[int]$retrieved = ($i + $result.Chromeosdevices.Count) - 1
Write-Verbose "Retrieved $retrieved Chrome OS Devices..."
[int]$i = $i + $result.Chromeosdevices.Count
}
until (!$result.NextPageToken)
}
}
}
catch {
if ($ErrorActionPreference -eq 'Stop') {
$PSCmdlet.ThrowTerminatingError($_)
}
else {
Write-Error $_
}
}
}
}
Loading

0 comments on commit d2507d6

Please sign in to comment.