I'll preface that I have Zero knowledge of PowerShell so I'm a complete NOOB here! Please excuse my ignorance. I need to replace an existing file on users computers (Laptops at local office & Remotely) to the "C:\ProgramData\subfolder\directory" location. This is a profile.xml file related to Cisco AnyConnect, and it will need to be updated at least one more time. I wanted to use SCCM because we have users who are remote 100% and don't regularly connect to VPN to get any group policy updates.
I've created a Configuration Item in SCCM and have a discovery script to see if the file exists in the directory (as SOME users might have old versions of AnyConnect BEFORE we started creating a profile/connection list to the application with our imaging system etc. and could have no profile.xml file at all).
The script I've tried works locally when I run it...but won't work in sysinternals, so I don't think it's executing on the test Laptops I have in the collection.
##Discovery script
test-path $ProfileList
$ProfileList = "C:\ProgramData\Cisco\Cisco AnyConnect Secure Mobility Client\Profile\profile.xml"
##Remediation
No clue what to put here...but this what I've tried running in PS as Admin...doesn't work otherwise.
Get-ChildItem "\\server\FileShares\VPN_ProfileList\profile.xml" | sort LastWriteTime | select -last 1 | copy-item -Destination "C:\ProgramData\Cisco\Cisco AnyConnect Secure Mobility Client\Profile\profile.xml" -Force