Forum Discussion
Copy a OVPN file in Powershell from Intune
- 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 - Chris_White_81Sep 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 28, 2022Bronze ContributorGot it, , my test has not worked either. I will update the thread with my test soon.
Moe - Chris_White_81Sep 28, 2022Copper Contributor
Moe_Kinani Ill try that Moe, ive just thought sod it and pushed it out to all users, for some reason it says its installed on a couple of machines and failed on 10, so im wondering if its something on my machine, which ive been mostly using for testing. ive attached an Intune logfile if that helps anyone, just looking at it myself now.
- Moe_KinaniSep 28, 2022Bronze Contributor
Hi Chris,
You may need to change you powershell script to the one below, I have test it on my machine now.
$Path = New-item -ItemType directory -force -path "c:\users\%username%\OpenVPN\config\"
Copy-item -path $Source -Destination $path -Recurse -ForceUPDATE:
My test has not work, I will update you soon
- Chris_White_81Sep 28, 2022Copper ContributorFrom being deployed by endpoint i mean, because it runs fine if i run it on the local machine. its just the remote installation that fails
- Chris_White_81Sep 28, 2022Copper ContributorNo luck, im wondering if theres something else at play here on the client machine. Can endpoint protection stop these powershell scripts from running?