diff --git a/CHANGELOG.md b/CHANGELOG.md index bf8f1d72..fd256fa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog * [Changelog](#changelog) + * [2.20.2](#2202) * [2.20.1](#2201) * [2.20.0](#2200) * [2.19.0](#2190) @@ -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) diff --git a/PSGSuite/PSGSuite.psd1 b/PSGSuite/PSGSuite.psd1 index fa40ce43..700666a9 100644 --- a/PSGSuite/PSGSuite.psd1 +++ b/PSGSuite/PSGSuite.psd1 @@ -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' diff --git a/PSGSuite/Public/Security/Remove-GSMobileDevice.ps1 b/PSGSuite/Public/Security/Remove-GSMobileDevice.ps1 index 106f3090..e751da14 100644 --- a/PSGSuite/Public/Security/Remove-GSMobileDevice.ps1 +++ b/PSGSuite/Public/Security/Remove-GSMobileDevice.ps1 @@ -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")] @@ -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) @@ -49,4 +49,4 @@ } } } -} \ No newline at end of file +} diff --git a/PSGSuite/Public/Security/Update-GSMobileDevice.ps1 b/PSGSuite/Public/Security/Update-GSMobileDevice.ps1 new file mode 100644 index 00000000..a6ab68d0 --- /dev/null +++ b/PSGSuite/Public/Security/Update-GSMobileDevice.ps1 @@ -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 $_ + } + } + } +} diff --git a/README.md b/README.md index cfe403f7..79a425fb 100644 --- a/README.md +++ b/README.md @@ -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)