Updated Workspace One Access module to include Get-UEMConfig and Remove-UEMConfig

This commit is contained in:
Alan Renouf
2020-04-15 14:09:13 -07:00
parent 20f387d2cf
commit 500e4022e7
2 changed files with 117 additions and 2 deletions

View File

@@ -12,7 +12,7 @@
RootModule = 'VMware.WorkspaceOneAccess.psm1' RootModule = 'VMware.WorkspaceOneAccess.psm1'
# Version number of this module. # Version number of this module.
ModuleVersion = '1.0.0' ModuleVersion = '1.0.1'
# Supported PSEditions # Supported PSEditions
# CompatiblePSEditions = @() # CompatiblePSEditions = @()
@@ -37,7 +37,7 @@ PowerShellVersion = '6.0'
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'Connect-WorkspaceOneAccess','Get-WSDirectory','Get-WSIdentityProvider','Get-WSOrgNetwork','New-WS3rdPartyIdentityProvider','New-WSJitDirectory','Remove-WS3rdPartyIdentityProvider','Remove-WSDirectory' FunctionsToExport = 'Connect-WorkspaceOneAccess','Get-WSDirectory','Get-WSIdentityProvider','Get-WSOrgNetwork','New-WS3rdPartyIdentityProvider','New-WSJitDirectory','Remove-WS3rdPartyIdentityProvider','Remove-WSDirectory', "Get-UEMConfig", "Remove-UEMConfig"
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @() CmdletsToExport = @()

View File

@@ -569,4 +569,119 @@ Function Remove-WS3rdPartyIdentityProvider {
} else { } else {
Write-Host "`nUnable to find Identity Provider $Name" Write-Host "`nUnable to find Identity Provider $Name"
} }
}
Function Get-UEMConfig {
<#
.NOTES
===========================================================================
Created by: Alan Renouf
Date: 04/15/2020
Organization: VMware
Blog: http://virtu-al.net
Twitter: @alanrenouf
===========================================================================
.SYNOPSIS
Retrieves UEM Configuration from Workspace One Access
.DESCRIPTION
This cmdlet retrieves the UEM Configuration from Workspace One Access
.EXAMPLE
Get-UEMConfig
.EXAMPLE
Get-UEMConfig
#>
Param (
[Switch]$Troubleshoot
)
$directoryHeaders = @{
"Authorization"=$global:workspaceOneAccessConnection.headers.Authorization;
}
$directoryUrl = $global:workspaceOneAccessConnection.Server + "/SAAS/jersey/manager/api/tenants/tenant/airwatchoptin/config"
$method = "GET"
if($Troubleshoot) {
Write-Host -ForegroundColor cyan "`n[DEBUG] - $method`n$directoryUrl`n"
}
try {
if($PSVersionTable.PSEdition -eq "Core") {
$results = Invoke-Webrequest -Uri $directoryUrl -Method $method -UseBasicParsing -Headers $directoryHeaders -SkipCertificateCheck
} else {
$results = Invoke-Webrequest -Uri $directoryUrl -Method $method -UseBasicParsing -Headers $directoryHeaders
}
} catch {
if($_.Exception.Response.StatusCode -eq "Unauthorized") {
Write-Host -ForegroundColor Red "`nThe Workspace One session is no longer valid, please re-run the Connect-WorkspaceOne cmdlet to retrieve a new token`n"
break
} else {
Write-Error "Error in retrieving UEM Configuration"
Write-Error "`n($_.Exception.Message)`n"
break
}
}
if($results.StatusCode -eq 200) {
$config = ([System.Text.Encoding]::ASCII.GetString($results.Content) | ConvertFrom-Json)
$config
}
}
Function Remove-UEMConfig {
<#
.NOTES
===========================================================================
Created by: Alan Renouf
Date: 04/15/2020
Organization: VMware
Blog: http://virtu-al.net
Twitter: @alanrenouf
===========================================================================
.SYNOPSIS
Removes the UEM Configuration from Workspace One Access
.DESCRIPTION
This cmdlet removes the UEM Configuration from Workspace One Access, there can only be one configuration.
.EXAMPLE
Remove-UEMConfig
.EXAMPLE
Remove-UEMConfig
#>
Param (
[Switch]$Troubleshoot
)
$directoryHeaders = @{
"Authorization"=$global:workspaceOneAccessConnection.headers.Authorization;
}
$directoryUrl = $global:workspaceOneAccessConnection.Server + "/SAAS/jersey/manager/api/tenants/tenant/airwatchoptin/config"
$method = "DELETE"
if($Troubleshoot) {
Write-Host -ForegroundColor cyan "`n[DEBUG] - $method`n$directoryUrl`n"
}
try {
if($PSVersionTable.PSEdition -eq "Core") {
$results = Invoke-Webrequest -Uri $directoryUrl -Method $method -UseBasicParsing -Headers $directoryHeaders -SkipCertificateCheck
} else {
$results = Invoke-Webrequest -Uri $directoryUrl -Method $method -UseBasicParsing -Headers $directoryHeaders
}
} catch {
if($_.Exception.Response.StatusCode -eq "Unauthorized") {
Write-Host -ForegroundColor Red "`nThe Workspace One session is no longer valid, please re-run the Connect-WorkspaceOne cmdlet to retrieve a new token`n"
break
} else {
Write-Error "Error in deleting UEM Configuration"
Write-Error "`n($_.Exception.Message)`n"
break
}
}
if($results.StatusCode -eq 200) {
Write-Host "`nSuccessfully deleted UEM Configuration"
}
} }