I have butchered a few scripts and I am having trouble getting this one to work.
Using an application to deploy software, I can run a custom script post-deployment.
This application is copying the script and a bunch of files to a location before launching them. The folder path could be random so I want to use the script location.
- \Path
- Script
- File 1
- File 2
I want to copy File 2 to the Users %LOCALAPPDATA% paths. The directory structure does not exist yet in the Users AppData folder. I need to create the folder structure during or before the copy.
C:\users*\AppData\Local\NewApplication\Folder\
#Declare location of the XML file using spli-path. Copy XML file to all user %LOCALAPPDATA% paths and create folder structure
$scriptPath = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$Source = Join-Path $scriptPath 'Script.ps1'
$Destination = 'C:\users\*\AppData\Local\NewApplication\Folder\'
Get-ChildItem $Destination | ForEach-Object {Copy-Item -Path $Source -Destination $_ -Force -Recurse}
Exit $LASTEXITCODE
Thank you so much.