Backup Firefox profile from logged on user
Dear community,
im bothering myself at the moment with a silly little problem regarding backup a folder when using pdq deploy enterprise 12
Normally i would assume, that when updating firefox browser using pdq deploy the profile folder wont be affected nor beeing destroyed by any reason. Yet for backup issue this backup is recommended from a department before browser update is done.
´The main goal should be, that the firefox profile folder which is found usualy in this path -> %userprofile%\AppData\Roaming\Mozilla\Profiles\ (assuming its for Windows 7) from the logged on user to a local backup folder like c:\mozilla
Now i struggle with matching the deploy script for the logged on user to make sure i only grab the Mozilla profile folder of the logged on user.
Did someone else might had the same or similar issue to handle and could give me an idea how to solve this?
I do am aware that the logged on user condition might be part of the solution :)
Kind regards
Markus
Comments
I just wrote this and tested it on Windows 8.1, the path appears to be the same for the profile between Win 7 and 8.1, so should work as-is but the path might need a little tweaking.
Insert a powershell step and paste this code into the step, or save this code into a .ps1 file and Insert a Powershell Script into the Powershell step, whichever you want to do.
In the screenshot above I put the step right above the Install step on the imported package as an example, but really you could put it anywhere before the install step, in fact it might be best to grab that backup first before the package does anything else to the remote system. You can clearly see in the screenshot the big white window to paste code into, or the link below if you want to save this as a .ps1 file and insert it that way. Again, should make no difference which way you do it, I'll leave it up to you.
Here's the code:
If you are using Auto-Deployments, you can insert a Pre-Step and do a Powershell step there, so this will work no matter which way you need to use it.
Gah, Stephen beat me to it! I'll still post mine though, because I added oldest backup deletion :)
You know. I was going to add in some sort of deletion mechanism, but hesitated cause I couldn't decide how I wanted to do it. I like your approach very much. also, smart use of the $env:SYSTEMDRIVE. I always just assume people use C:\ haha.
Curiousity question: Why the use of write-output in your script? Does you wrapper capture that for output.log?
I have been trying to use Write-Output in Deploy scripts lately because Deploy throws a warning if you use Write-Host. It doesn't actually matter, but I prefer if the code I give people doesn't show that warning :).
Also, yes my output shows up in Output.log.
Write-Host is the devil. I never ever use it except in cases where I'm testing, but it gets either commented out, or changed to write-output in the final version of code. You can actually DO STUFF with write-output, whereas Write-Host is basically echo and worthless in production haha.
Good to know that Write-Output is put in output.log. That's actually extremely useful to know. I'll start being more verbose in things I'm both in my own stuff, and in the help I provide here! Thanks, Colby.
Thanks a lot for both comments, i appreciate your efford a lot :)
Ill test it out and im pretty sure it helps me to solve my stuff in this issue!
Kind regards
Markus
Please sign in to leave a comment.