Forum Discussion
Copy a OVPN file in Powershell from Intune
Sounds easy, my powershell script works fine if i run it on my machine, it copies the file into the %USERPROFILE%\OpenVPN\config folder. Its packaged up using the Intunewinapp program, but when i put it into intune it fails to install and copy the file over. Culd something like defender be stopping this process? The script works, the intune package works when launched from powershell, so what causes it to fail when i run it as a win32 app from intune? Anyone had this issue before?
This is my script;
$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
$Source = "$PSScriptRoot\Thornes.ovpn"
$Destination = "$env:USERPROFILE\OpenVPN\config\"
Copy-Item -Path $Source -Destination $Destination -Recurse -Force
Thanks
- Hi... %userprofile% ... I am missing how the install behavior is configured
Is it configured as System?
If run as system, maybe searching the logged in user first? and change the destination to match the username who has explorer running?
$username = (get-process -name "explorer" -includeusername).username
$username = ($username -split '\\')[1]
$Destination = c:\users\$username\OpenVPN\config\"- Chris_White_81Copper Contributor
Sorry, yes, its configured to run as system, if i run it on my machine locally it does what it should be. ill look at your suggestions though and see if i can get it working thanks.
Guess where the %userprofile% resolves to when deploying it as system : C:\Windows\System32\Config\systemprofile 🙂
and you could always use wildcards in the copy process c:\users\*\openvpn