Forum Discussion
Chris_White_81
Sep 27, 2022Copper Contributor
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...
Moe_Kinani
Sep 28, 2022Bronze Contributor
Got it, , my test has not worked either. I will update the thread with my test soon.
Moe
Moe
Chris_White_81
Sep 28, 2022Copper Contributor
Moe_Kinani ah right, yea, it didnt work when i tried thee path like that either. So, here is the current install so far, out of 14 machines its only run on 2. So i think its at the client side. All the machines are domain joined and from the same image. All users are just standard users, but there must be something client side i think. The script fundamentally does work. Attached an image of the install status
- Moe_KinaniSep 29, 2022Bronze ContributorHi Chris,
Can you adjust your script similar to the one below? I have tested it and worked in my test machine.
Moe
#Get only the copied file
$copiedfile = Get-ChildItem $PSScriptRoot -File
#Get all Profiles with Exclude basic Profiles
$Excluded_Profiles = @( 'Default User', 'All Users', 'Default', 'Public' )
$Profiles = Get-ChildItem 'c:\users\' -Directory -force | Where-Object { $_.BaseName -notin $excluded_profiles }
#Get Folder Path to place the File
$targetFolder = "\OpenVPN\config”
foreach ($ProfilePath in $Profiles.FullName) {
$Destination = Join-Path -Path $ProfilePath -ChildPath $TargetFolder
try {
if (-not (Test-Path $Destination -ErrorAction Stop)) {
New-Item -Path $Destination -Itemtype Directory -ErrorAction Stop
}
Copy-Item -Path $copiedfile -Destination $Destination -Force -ErrorAction Stop
} catch {}
}
Source:
https://github.com/slaet/IntuneTeams/blob/master/copyTeamsBG.ps1