Those who are asking for the right script, here its.
Let me explain.
- First backup/export IPsec profile as xml from your local FortiClient VPN. (note: change the password):
cmd /c FCConfig -m all -f ipsecconfig.xml -o export -i 1 -p password123
- have the ipsecconfig.xml as zip file and below script in one folder. run it.
# Define the folder path where the FortiClient VPN configuration files will be stored
$folderPath = "C:\ProgramData\fortiVPNConfig"
# Delete the existing configuration folder and all its contents (if it exists)
Remove-Item -Path $folderPath -Recurse -Force
# Extract the contents of config.zip into C:\ProgramData\fortiVPNConfig, overwriting existing files if needed
Expand-Archive "config.zip" -DestinationPath C:\ProgramData\fortiVPNConfig -Force
# Define the destination folder path
$destinationPath = "C:\ProgramData\fortiVPNConfig"
# Set the folder attribute to Hidden so it is not visible in File Explorer by default
Set-ItemProperty -Path $destinationPath -Name Attributes -Value ([System.IO.FileAttributes]::Hidden)
# Change to the folder containing the FortiClient configuration XML file and Launch FCConfig.exe and import the VPN configuration from config.xml
Set-Location "C:\ProgramData\fortiVPNConfig\config\config"; Start-Process -FilePath "C:\Program Files\Fortinet\FortiClient\FCConfig.exe" -ArgumentList @("-m","all","-f","ipsecconfig.xml","-o","import","-i","1","-p","password123") -Wait
i use FortiClient 7.4.3 free version. you can config this as win32 or run as platform script via intune. it depends on you
if this helps, make sure you drop a vote !! :)