Delivering multiple scripts

Hello,

I am attempting to deliver 2 scripts, one is to run as the logged in user and the other as the agent. I used the software deployment wizard and grabbed a folder but I cannot move the scripts. When the folder is extracted is it extracted to the _Download\FOLDERNAME\Scipt.ps1?

Completed extract c5fcddcc10f36d80828d4be85acf8c9cfac9f5e6
Failed wait move “__Download\ODM\GPOScript062222-1.ps1” “C:\TEMP\GPOScript062222-1.ps1”

I have tried both with and without the folder name

Two things:
A copy will fail if the target file already exists, so you need to delete it first
and you only need ‘wait’ if you are invoking an external command - ‘move’ is actionscript, so doesn’t need the wait

extract c5fcddcc10f36d80828d4be85acf8c9cfac9f5e6
delete "C:\TEMP\GPOScript062222-1.ps1"
move "__Download\ODM\GPOScript062222-1.ps1" "C:\TEMP\GPOScript062222-1.ps1"

The delete command does not error if the target isn’t there, so you don’t need to test for presence beforehand

TRN,

Thanks for the reply. The script is not in the TEMP directory at this time. I did have the delete in there for a few of the test but removed it to simplify the script.

OK - have you removed the ‘wait’ that precedes ‘move’?

Completed extract c5fcddcc10f36d80828d4be85acf8c9cfac9f5e6
Completed delete “C:\TEMP\GPOScript062222-1.ps1”
Completed delete “C:\TEMP\GPOScript062222-2.ps1”
Failed move “__Download\ODM\GPOScript062222-1.ps1” “C:\TEMP\GPOScript062222-1.ps1”

I also do not see anything in the _Download folder

I had it working on the 17th, tried a larger group and it failed to actually run so we broke the script into 2 scripts, one to run as current user and 1 as the agent to change HKLM settings.

This was from the 17th
Completed extract a839f084d666b858455bb798c088c0bc5bc41170
Completed delete C:\TEMP\GPOScript061722.ps1
Completed move “__Download\GPOScript061722.ps1” "C:\TEMP\GPOScript061722.ps1"
Completed waithidden cmd.exe /C icacls.exe C:\temp /grant Everyone:W
Completed override wait
Completed hidden=true
Completed runas=currentuser
Completed wait “C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe” -ExecutionPolicy Bypass -File C:\TEMP\GPOScript061722.ps1
Completed delete C:\TEMP\GPOScript061722.ps1

You can extract directly to a named path though as @TRN points out, the files do need to be deleted first.

if {not exists folder "C:\TEMP"}
	folder create "C:\TEMP"
endif

delete "C:\TEMP\GPOScript062222-1.ps1"
delete "C:\TEMP\GPOScript062222-2.ps1"
extract c5fcddcc10f36d80828d4be85acf8c9cfac9f5e6 C:\TEMP

One other point is that using copy instead of move can sometimes avoid issues with permissions the extracted files may retain that are inherited from the downloads folder.

Good point re: copy being better than move

If there is nothing in __Download then neither copy nor move will work, but this is harder to debug because Bigfix tidies up after itself. Extracting to another folder as suggested by @SLB is helpful in that case, because the alternative target is not within the remit of the housekeeping activity

We got it! I can’t thank you all enough! The extract to the TEMP and adding the full path to powershell fixed it. I was able to run -1 script as the current user and the -2 as the agent to modify the HKLM keys.

Thanks again!

1 Like