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?
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
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.
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
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.
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.