Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/cosine83/powershell
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Grathwohl committed Aug 12, 2023
2 parents 10565af + 159e8fb commit 4fbd07a
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions Update-GlobalProtectClientPortals.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<#
.PURPOSE
The purpose of this script is to update existing installs of the GlobalProtect client to have the new VPN portals. Gateways are populated from the firewall side.
.DEPLOYMENT
To properly write to HKCU, the user will need to be logged in and the script executed in user context. If deploying via MDM solution, deploying as SYSTEM
results in the keys being written to HKU and not applied to the user. The HKLM keys seem to be loaded at install but have no impact on the application beyond redundancy.
.NOTES
- Restarting the service requires admin privileges or delegated permissions to the service for the user(s).
- Deploying via MDM in user context with admin will pop a UAC prompt if the service restarts are uncommented.
- If the service isn't restarted, the portal updates get applied on next login/restart or manual restart of the service.
#>

#Stop-Service -Name "PanGPS" -Force

$machineSettingsRegPath = "HKLM:\SOFTWARE\Palo Alto Networks\GlobalProtect\Settings"
$userSettingsRegPath = "HKCU:\SOFTWARE\Palo Alto Networks\GlobalProtect\Settings"
$bajaPortalUserPathTest = "$userSettingsRegPath\vpn.domain.com"
$moabPortalUserPathTest = "$userSettingsregPath\vpn2.domain.com"
$renoPortalUserPathTest = "$userSettingsregPath\vpn3.domain.com"
$bajaPortalMachinePathTest = "$machineSettingsRegPath\vpn.domain.com"
$moabPortalMachinePathTest = "$machineSettingsregPath\vpn2.domain.com"
$renoPortalMachinePathTest = "$machineSettingsregPath\vpn3.domain.com"

If(!(Test-Path $bajaPortalUserPathTest)) {
New-Item $bajaPortalUserPathTest -Force
}

If(!(Test-Path $moabPortalUserPathTest)) {
New-Item $moabPortalUserPathTest -Force
}

If(Test-Path $renoPortalUserPathTest) {
Remove-Item $renoPortalUserPathTest -Force
}

If(!(Test-Path $bajaPortalMachinePathTest)) {
New-Item $bajaPortalMachinePathTest -Force
}

If(!(Test-Path $moabPortalMachinePathTest)) {
New-Item $moabPortalMachinePathTest -Force
}

If(Test-Path $renoPortalMachinePathTest) {
Remove-Item $renoPortalMachinePathTest -Force
}

$testUserPanSettings = Get-ItemProperty "$userSettingsRegPath"
If ($testUserPanSettings.LastUrl -eq "vpn3.domain.com") {
Set-ItemProperty -Path $userSettingsRegPath -Name "LastUrl" -Value "vpn.domain.com" -Force -Verbose
}

$testMachinePanSettings = Get-ItemProperty "$machineSettingsRegPath"
If ($testMachinePanSettings.LastUrl -eq "vpn3.domain.com") {
Set-ItemProperty -Path $machineSettingsRegPath -Name "LastUrl" -Value "vpn.domain.com" -Force -Verbose
}

#Start-Service -Name "PanGPS"

0 comments on commit 4fbd07a

Please sign in to comment.