Renames in a user Profile and move a file

Hello - I am still very new to Big Fix and have a questions about how to do file renames in a user profile and also how to move a file. I wrote a PS1 script for this that works well but I cant seem to get it working within BigFix. Here are the commands from the PS1 script:

Rename-Item -Path “$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Zoom\Start Zoom.lnk” -NewName “Zoom.lnk” -ErrorAction SilentlyContinue

Copy-Item “$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Zoom\Zoom.lnk” -Destination “C:\ProgramData\Microsoft\Windows\Start Menu\Programs” -ErrorAction SilentlyContinue

Any documentation or advice is very welcomed.

The Bigfix action will be running as SYSTEM so will not have access to the logged in user environment. You can have the action run as the logged in user by using the override command to run as current user.

@SLB

Thank you - this was a huge step forward and I can now get BF to see the machine and too run the script. However the power shell script I create in the script still does not work. It says it has run in BF but does not actually change anything and I suspect that I am using the Keywords wrong (I tried several of them but they are removed below). Can you take a look and advise? Here is what I have:

//Create PS File
createfile until end

<#

Title :ZoomRename
Description :This Powershell script changes the Zoom Link name from within its directory and moves it to the correct start menu location.
Author :NA
Date :7/19/2021
Directories :USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Zoom
P/S :

#>

Rename-Item -Path “$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Zoom\Start Zoom.lnk” -NewName “Zoom.lnk” -ErrorAction SilentlyContinue

Copy-Item “$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Zoom\Zoom.lnk” -Destination “C:\ProgramData\Microsoft\Windows\Start Menu\Programs” -ErrorAction SilentlyContinue

end

//saves the ps1 file
move __createfile C:\mwa\Zoom\ZoomRenameStartMenuCopy.ps1

override wait
wait C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy bypass -file “C:\mwa\Zoom\ZoomRenameStartMenuCopy.ps1”

if {exists file “C:\mwa\Zoom\ZoomRenameStartMenuCopy.ps1” }
delete "C:\mwa\zoom\ZoomRenameStartMenuCopy.ps1"
endif

Have you tried the FixletDebugger to debug the actionscript? Its very useful, though you have to bear in mind that would be running in the user context so will not behave exactly as it would when issuing the fixlet via the admin console. For me it throw an error on the move as I would not have the folder structure you are expecting. That could be an issue if your endpoints do not have that folder and maybe thats somethign you should cater from in your actionscript with something like a foldercreate

Try this

createfile until end

<#
Title :ZoomRename
Description :This Powershell script changes the Zoom Link name from within its directory and moves it to the correct start menu location.
Author :NA
Date :7/19/2021
Directories :USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Zoom
P/S :
#>

Rename-Item -Path "$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Zoom\Start Zoom.lnk" -NewName "Zoom.lnk" -ErrorAction SilentlyContinue

Copy-Item "$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Zoom\Zoom.lnk" -Destination "C:\ProgramData\Microsoft\Windows\Start Menu\Programs" -ErrorAction SilentlyContinue

end

//saves the ps1 file
folder create C:\mwa\Zoom
move __createfile C:\mwa\Zoom\ZoomRenameStartMenuCopy.ps1

override wait
hidden=true
runas=currentuser
wait C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy bypass -file "C:\mwa\Zoom\ZoomRenameStartMenuCopy.ps1"

if {exists file "C:\mwa\Zoom\ZoomRenameStartMenuCopy.ps1"}
	delete "C:\mwa\zoom\ZoomRenameStartMenuCopy.ps1"
endif
1 Like

I believe you also have to specify “RunAs=current user” immediately following the “override wait” line.

However, being that this script is copying a file to the system’s start menu folder, the powershell script itself would likely fail unless the user has admin rights.

If that’s the case, you would need to subtitue the override command with parameters that are set to the desired user profile so the script still runs with system level privileges

1 Like

Yes, good point @EricReichard. it does also need that, maybe also to make it hidden so no popups for the user. Editied accordingly