Fix Meraki VPN services with Powershell after running FortiClient
#Powershell #Windows #Networking
I have a client that is transitioning their network equipment from Fortigate to Meraki. Part of this transition is testing the Meraki Client VPN instead of the FortiClient application.
We found that that on first run, the FortiClient VPN app disables some services that are needed for the Meraki VPN connection to successfully authenticate. If users don't have Local Admin permissions, they are unable to make any changes to the services to fix the issue.
To work around this, I created a small PowerShell script that can be deployed through GPO or Intune. It stops all of the FortiClient services and processes and re-enables the services that Meraki's VPN uses. It also creates a transcript and stores the log to C:\Fix-MerakiVPN.log
that you can use for troubleshooting.
Here's the script:
#Requires -Version 1
<#
.SYNOPSIS
Closes and disables FortiClient VPN services and apps. Checks and configures Windows services to allow Meraki VPN connection.
.DESCRIPTION
Closes and disables FortiClient VPN services and apps. Checks and configures Windows services to allow Meraki VPN connection.
.INPUTS
None
.OUTPUTS
Log file stored in C:\Fix-MerakiVPN.log
.NOTES
Version: 1.0
Author: Tim D'Annecy
Creation Date: 2022-06-07
Purpose/Change: Initial script development
.EXAMPLE
Fix-MerakiVPN.ps1
#>
$ServicesToStop = 'FA_Scheduler'#, 'FMAPOService'
$ServicesToStart = 'PolicyAgent', 'IKEEXT'
$AppsToStop = 'FortiClient', 'FortiSettings', 'FortiSSLVPNdaemon', 'FortiTray'
function Fix-MerakiVPN {
foreach ($App in $AppsToStop) {
if (Get-Process -Name $App -ErrorAction SilentlyContinue) {
Write-Host 'Application running. Stopping:' $App
Stop-Process -Name $App -Force
}
else {
Write-Host 'OK: Application not running or not installed:' $App
}
}
foreach ($service in $ServicesToStop) {
if ((Get-Service $service -ErrorAction SilentlyContinue).status -eq 'Running') {
Write-Host 'Service running. Stopping:' $service
$ServicePID = (get-wmiobject win32_service | Where-Object { $_.name -eq $service }).processID
Stop-Process $ServicePID -Force
Set-Service $service -StartupType Disabled
}
else {
Write-Host 'OK: Service not running or not installed:' $service
}
}
foreach ($service in $ServicesToStart) {
if ((Get-Service $service -ErrorAction SilentlyContinue).status -eq 'Running') {
Write-Host 'OK: Service running:' $service
}
else {
Write-Host 'Service not running. Starting:' $service
Set-Service $service -StartupType Automatic -Status Running
Start-Service $service
}
}
}
Start-Transcript -Path 'C:\Fix-MerakiVPN.log' -Append
Fix-MerakiVPN
Stop-Transcript