Skip to content

Commit 500e402

Browse files
committed
Updated Workspace One Access module to include Get-UEMConfig and Remove-UEMConfig
1 parent 20f387d commit 500e402

2 files changed

Lines changed: 117 additions & 2 deletions

File tree

Modules/VMware.WorkspaceOneAccess/VMware.WorkspaceOneAccess.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'VMware.WorkspaceOneAccess.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.0.0'
15+
ModuleVersion = '1.0.1'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -37,7 +37,7 @@ PowerShellVersion = '6.0'
3737

3838
# 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.
3939

40-
FunctionsToExport = 'Connect-WorkspaceOneAccess','Get-WSDirectory','Get-WSIdentityProvider','Get-WSOrgNetwork','New-WS3rdPartyIdentityProvider','New-WSJitDirectory','Remove-WS3rdPartyIdentityProvider','Remove-WSDirectory'
40+
FunctionsToExport = 'Connect-WorkspaceOneAccess','Get-WSDirectory','Get-WSIdentityProvider','Get-WSOrgNetwork','New-WS3rdPartyIdentityProvider','New-WSJitDirectory','Remove-WS3rdPartyIdentityProvider','Remove-WSDirectory', "Get-UEMConfig", "Remove-UEMConfig"
4141

4242
# 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.
4343
CmdletsToExport = @()

Modules/VMware.WorkspaceOneAccess/VMware.WorkspaceOneAccess.psm1

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,4 +569,119 @@ Function Remove-WS3rdPartyIdentityProvider {
569569
} else {
570570
Write-Host "`nUnable to find Identity Provider $Name"
571571
}
572+
}
573+
574+
Function Get-UEMConfig {
575+
<#
576+
.NOTES
577+
===========================================================================
578+
Created by: Alan Renouf
579+
Date: 04/15/2020
580+
Organization: VMware
581+
Blog: http://virtu-al.net
582+
Twitter: @alanrenouf
583+
===========================================================================
584+
585+
.SYNOPSIS
586+
Retrieves UEM Configuration from Workspace One Access
587+
.DESCRIPTION
588+
This cmdlet retrieves the UEM Configuration from Workspace One Access
589+
.EXAMPLE
590+
Get-UEMConfig
591+
.EXAMPLE
592+
Get-UEMConfig
593+
#>
594+
Param (
595+
[Switch]$Troubleshoot
596+
)
597+
598+
$directoryHeaders = @{
599+
"Authorization"=$global:workspaceOneAccessConnection.headers.Authorization;
600+
}
601+
602+
$directoryUrl = $global:workspaceOneAccessConnection.Server + "/SAAS/jersey/manager/api/tenants/tenant/airwatchoptin/config"
603+
$method = "GET"
604+
605+
if($Troubleshoot) {
606+
Write-Host -ForegroundColor cyan "`n[DEBUG] - $method`n$directoryUrl`n"
607+
}
608+
609+
try {
610+
if($PSVersionTable.PSEdition -eq "Core") {
611+
$results = Invoke-Webrequest -Uri $directoryUrl -Method $method -UseBasicParsing -Headers $directoryHeaders -SkipCertificateCheck
612+
} else {
613+
$results = Invoke-Webrequest -Uri $directoryUrl -Method $method -UseBasicParsing -Headers $directoryHeaders
614+
}
615+
} catch {
616+
if($_.Exception.Response.StatusCode -eq "Unauthorized") {
617+
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"
618+
break
619+
} else {
620+
Write-Error "Error in retrieving UEM Configuration"
621+
Write-Error "`n($_.Exception.Message)`n"
622+
break
623+
}
624+
}
625+
626+
if($results.StatusCode -eq 200) {
627+
$config = ([System.Text.Encoding]::ASCII.GetString($results.Content) | ConvertFrom-Json)
628+
$config
629+
}
630+
}
631+
632+
Function Remove-UEMConfig {
633+
<#
634+
.NOTES
635+
===========================================================================
636+
Created by: Alan Renouf
637+
Date: 04/15/2020
638+
Organization: VMware
639+
Blog: http://virtu-al.net
640+
Twitter: @alanrenouf
641+
===========================================================================
642+
643+
.SYNOPSIS
644+
Removes the UEM Configuration from Workspace One Access
645+
.DESCRIPTION
646+
This cmdlet removes the UEM Configuration from Workspace One Access, there can only be one configuration.
647+
.EXAMPLE
648+
Remove-UEMConfig
649+
.EXAMPLE
650+
Remove-UEMConfig
651+
#>
652+
Param (
653+
[Switch]$Troubleshoot
654+
)
655+
656+
$directoryHeaders = @{
657+
"Authorization"=$global:workspaceOneAccessConnection.headers.Authorization;
658+
}
659+
660+
$directoryUrl = $global:workspaceOneAccessConnection.Server + "/SAAS/jersey/manager/api/tenants/tenant/airwatchoptin/config"
661+
$method = "DELETE"
662+
663+
if($Troubleshoot) {
664+
Write-Host -ForegroundColor cyan "`n[DEBUG] - $method`n$directoryUrl`n"
665+
}
666+
667+
try {
668+
if($PSVersionTable.PSEdition -eq "Core") {
669+
$results = Invoke-Webrequest -Uri $directoryUrl -Method $method -UseBasicParsing -Headers $directoryHeaders -SkipCertificateCheck
670+
} else {
671+
$results = Invoke-Webrequest -Uri $directoryUrl -Method $method -UseBasicParsing -Headers $directoryHeaders
672+
}
673+
} catch {
674+
if($_.Exception.Response.StatusCode -eq "Unauthorized") {
675+
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"
676+
break
677+
} else {
678+
Write-Error "Error in deleting UEM Configuration"
679+
Write-Error "`n($_.Exception.Message)`n"
680+
break
681+
}
682+
}
683+
684+
if($results.StatusCode -eq 200) {
685+
Write-Host "`nSuccessfully deleted UEM Configuration"
686+
}
572687
}

0 commit comments

Comments
 (0)