Skip to content

Commit

Permalink
!deploy v2.20.2 with updates to Mobile Device commands for #120
Browse files Browse the repository at this point in the history
## 2.20.2

* [Issue #120](#120)
  * Added: `Update-GSMobileDevice` to allow taking action on Mobile Devices
  * Fixed: Bug in `Remove-GSMobileDevice` with incorrect variable name
  • Loading branch information
scrthq authored Nov 25, 2018
2 parents 85d9168 + dcd8240 commit 404ba5d
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 7 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.20.2](#2202)
* [2.20.1](#2201)
* [2.20.0](#2200)
* [2.19.0](#2190)
Expand Down Expand Up @@ -63,6 +64,12 @@

***

## 2.20.2

* [Issue #120](https://github.com/scrthq/PSGSuite/issues/120)
* Added: `Update-GSMobileDevice` to allow taking action on Mobile Devices
* Fixed: Bug in `Remove-GSMobileDevice` with incorrect variable name

## 2.20.1

* [Issue #121](https://github.com/scrthq/PSGSuite/issues/121)
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.20.1'
ModuleVersion = '2.20.2'

# ID used to uniquely identify this module
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'
Expand Down
12 changes: 6 additions & 6 deletions PSGSuite/Public/Security/Remove-GSMobileDevice.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
<#
.SYNOPSIS
Removes a mobile device from Device Management
.DESCRIPTION
Removes a mobile device from Device Management
.PARAMETER ResourceID
The unique Id of the mobile device you would like to remove
.EXAMPLE
Remove-GSMobileDevice -ResourceId 'AFiQxQ8Qgd-rouSmcd2UnuvhYV__WXdacTgJhPEA1QoQJrK1hYbKJXm-8JFlhZOjBF4aVbhleS2FVQk5lI069K2GULpteTlLVpKLJFSLSL'
Removes the mobile device with the specified Id
#>
[cmdletbinding(SupportsShouldProcess = $true,ConfirmImpact = "High")]
Expand All @@ -31,7 +31,7 @@
}
Process {
try {
foreach ($R in $DeviceId) {
foreach ($R in $ResourceId) {
if ($PSCmdlet.ShouldProcess("Removing Mobile Device '$R'")) {
Write-Verbose "Removing Mobile Device '$R'"
$request = $service.Mobiledevices.Delete($Script:PSGSuite.CustomerID,$R)
Expand All @@ -49,4 +49,4 @@
}
}
}
}
}
75 changes: 75 additions & 0 deletions PSGSuite/Public/Security/Update-GSMobileDevice.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
function Update-GSMobileDevice {
<#
.SYNOPSIS
Updates a mobile device with the action specified
.DESCRIPTION
Updates a mobile device with the action specified
.PARAMETER ResourceID
The unique Id of the mobile device you would like to update
.PARAMETER Action
The action to be performed on the device.
Acceptable values are:
* "admin_account_wipe": Remotely wipes only G Suite data from the device. See the administration help center for more information.
* "admin_remote_wipe": Remotely wipes all data on the device. See the administration help center for more information.
* "approve": Approves the device. If you've selected Enable device activation, devices that register after the device activation setting is enabled will need to be approved before they can start syncing with your domain. Enabling device activation forces the device user to install the Device Policy app to sync with G Suite.
* "block": Blocks access to G Suite data (mail, calendar, and contacts) on the device. The user can still access their mail, calendar, and contacts from a desktop computer or mobile browser.
* "cancel_remote_wipe_then_activate": Cancels a remote wipe of the device and then reactivates it.
* "cancel_remote_wipe_then_block": Cancels a remote wipe of the device and then blocks it.
.EXAMPLE
Update-GSMobileDevice -ResourceId 'AFiQxQ8Qgd-rouSmcd2UnuvhYV__WXdacTgJhPEA1QoQJrK1hYbKJXm-8JFlhZOjBF4aVbhleS2FVQk5lI069K2GULpteTlLVpKLJFSLSL' -Action approve
Approves the mobile device with the specified Id
#>
[cmdletbinding()]
Param
(
[parameter(Mandatory = $true,ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[String[]]
$ResourceId,
[parameter(Mandatory = $true)]
[ValidateSet('admin_account_wipe','admin_remote_wipe','approve','block','cancel_remote_wipe_then_activate','cancel_remote_wipe_then_block')]
[String]
$Action

)
Begin {
$serviceParams = @{
Scope = 'https://www.googleapis.com/auth/admin.directory.device.mobile'
ServiceType = 'Google.Apis.Admin.Directory.directory_v1.DirectoryService'
}
$service = New-GoogleService @serviceParams
$customerId = if ($Script:PSGSuite.CustomerID) {
$Script:PSGSuite.CustomerID
}
else {
"my_customer"
}
$body = New-Object 'Google.Apis.Admin.Directory.directory_v1.Data.MobileDeviceAction' -Property @{
Action = $Action
}
}
Process {
try {
foreach ($R in $ResourceId) {
Write-Verbose "Updating Mobile Device '$R' with Action '$Action'"
$request = $service.Mobiledevices.Action($body,$customerId,$R)
$request.Execute()
Write-Verbose "Mobile Device was successfully updated"
}
}
catch {
if ($ErrorActionPreference -eq 'Stop') {
$PSCmdlet.ThrowTerminatingError($_)
}
else {
Write-Error $_
}
}
}
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ Update-GSSheetValue Export-GSSheet

### Most recent changes

#### 2.20.2

* [Issue #120](https://github.com/scrthq/PSGSuite/issues/120)
* Added: `Update-GSMobileDevice` to allow taking action on Mobile Devices
* Fixed: Bug in `Remove-GSMobileDevice` with incorrect variable name

#### 2.20.1

* [Issue #121](https://github.com/scrthq/PSGSuite/issues/121)
Expand Down

0 comments on commit 404ba5d

Please sign in to comment.