Forum Discussion
dkingsb4
Apr 23, 2025Copper Contributor
Deploying PS Script as Application Doesn't Work
I've been trying desperately to get a powershell script to run on a target machine using MECM. First to note, I inherited a partially built MECM environment from my predecessor that wasn't documented...
- Apr 24, 2025
Your problem is that you are copying a file from a network share. This is because the script will run as local system account. As such you need to test your script as local system. This blog will show you how to do that. How to Access the Local System Account - Recast Software
You can solve this but including the license file with the script/setup. That is the simplest solution.
dkingsb4
Apr 25, 2025Copper Contributor
Yeah it's a pretty basic PS script.
# Define variables
$SourcePath1 = "<path/file>"
$DestinationPath1 = "<path/file>"
$SourcePath2 = "<path>"
$DestinationPath2 = "<path"
# Copy files from source to destination
try {
Copy-Item -Path $SourcePath1 -Destination $DestinationPath1 -Recurse -Force
Write-Host "Files copied successfully from '$SourcePath1' to '$DestinationPath1'."
Copy-Item -Path $SourcePath2 -Destination $DestinationPath2 -Recurse -Force
Write-Host "Files copied successfully from '$SourcePath2' to '$DestinationPath2'."
}
catch {
Write-Error "Error copying files: $($_.Exception.Message)"
exit 1
AhmedLS
Apr 26, 2025Copper Contributor
if you are running the script in user context the $DestinationPath is very important. unless the user has rights to the folder it wont work. anywhere outside the user profile actually wont work unless the user is admin.
you wrote that you ran the script manually and it worked. did you run it as a user or admin