Having to create this script over two days is not acceptable at Enterprise level
Disable the FA_Scheduler service
Set-Service -Name “FA_Scheduler” -StartupType Disabled
Define the path to the FortiClient command-line tool
Stop-process -name “fortiSSLVPNdaemon” -force
Start-Sleep -Seconds 10
taskkill /im FortiVPN.exe /t /f
taskkill /im FCDBLog.exe /t /f
taskkill /im FortiSettings.exe /t /f
taskkill /im FortiTray.exe /t /f
Kill the scheduler.exe process
Get-Process -Name “scheduler” -ErrorAction SilentlyContinue | Stop-Process -Force
Install FortiClient VPN
Write-Host “Installing FortiClient VPN…”
Start-Process Msiexec.exe -Wait -ArgumentList ‘/i FortiClient.msi /quiet /norestart’
Write-Host “FortiClient VPN installed.”
Start-Sleep -Seconds 5
Enable the FA_Scheduler service
Set-Service -Name “FA_Scheduler” -StartupType Automatic
Install VPN Profiles
$vpnKeyPath = “HKLM:\SOFTWARE\Fortinet\FortiClient\Sslvpn\Tunnels\COMPANYVPN”
if((Test-Path -LiteralPath $vpnKeyPath) -ne $true) {
Write-Host “Creating VPN profile…”
New-Item -Path $vpnKeyPath -Force -ErrorAction SilentlyContinue
}
Add VPN profile properties
Write-Host “Configuring VPN profile…”
New-ItemProperty -LiteralPath $vpnKeyPath -Name ‘Description’ -Value ‘whateveryourcompany’ -PropertyType String -Force -ErrorAction SilentlyContinue
New-ItemProperty -LiteralPath $vpnKeyPath -Name ‘Server’ -Value ‘vpn.yourcompany.domain:443’ -PropertyType String -Force -ErrorAction SilentlyContinue
New-ItemProperty -LiteralPath $vpnKeyPath -Name ‘promptusername’ -Value 1 -PropertyType DWord -Force -ErrorAction SilentlyContinue
New-ItemProperty -LiteralPath $vpnKeyPath -Name ‘promptcertificate’ -Value 0 -PropertyType DWord -Force -ErrorAction SilentlyContinue
New-ItemProperty -LiteralPath $vpnKeyPath -Name ‘ServerCert’ -Value ‘1’ -PropertyType String -Force -ErrorAction SilentlyContinue
New-ItemProperty -LiteralPath $vpnKeyPath -Name ‘sso_enabled’ -Value 1 -PropertyType DWord -Force -ErrorAction SilentlyContinue
New-ItemProperty -LiteralPath $vpnKeyPath -Name ‘use_external_browser’ -Value 1 -PropertyType DWord -Force -ErrorAction SilentlyContinue
Write-Host “VPN profile configured successfully.”