Is there any reason not to user powershell for backup scripts

As I’m getting back into the details of having my home computer environment setup as I want it, I’m about to add additional backups by using some sort of scripts to copy certain directories to other directories on different hardware.

I haven’t written BAT files for years, but these days all the talk seems to be about PowerShell for doing this kind of work. When I read the documentation, Microsoft talks about how it’s built on top of the .NET framework - which sounds great and all but also seems to add complexity.

I wonder if there are any reasons NOT to use PowerShell for making my backup scripts, just like (If you excuse the unix/linux comparison) back in the days people were discouraged to write bash scripts and encouraged to stick with /bin/sh instead?

Could e.g. good old BAT scripts for CMD have some sort of robustness or simplicity advantage?

1 Like

I know that command prompt is usually disabled for users, where powershell is not so guessing its mostly a security thing.

Q: Why use powershell when windows includes a backup program (which is VSS/Application aware)?

If you do decide to use Powershell, bear in mind default windows behaviour is to check code signature on it. You’ll need to disable code signing for either local or remote scripts, or sign your script.

Generating a code-signing cert, adding that cert as trusted to the machine, and signing would be the more secure way but its a pain in the ass if you don’t already have a PKI environment.

Powershell being built on .net is great from a flexibility perspective, you can do a LOT of funky stuff (by calling into WMI or .net APIs) with it that is either difficult or impossible with either native sh or cmd on Linux or Windows respectively. But using it to copy data around is like using a nail gun for post-it notes on your pin-board… Powershell will run slower than cmd, but it has a lot more features like issuing commands to remote machines over the network, foreach loops over collections of stuff, etc.

Unless you want to say, use Powershell for the more advanced glue logic (it’s a lot better than .cmd for that) and use that to generate parameters for robocopy for example?

Good questions. This is partly play / learning, partly that I want to do something else for my offline backup than what I seem to be able to do with either of the two backup tools I’ve yet found in Windows (File History and the older Windows 7 backup). I plainly just want a copy of some of my directories on a separate drive.

The first things I’ve thought about is just that - generating the right name for the new destination folder and then starting robocopy.

The question was rather if there was a reason not to take this as an opportunity to dig into Powershell.

Thanks for the signing info. I’ll look into that.

If that’s the case (a learning exercise), definitely play with powershell.

Powershell is very much worth learning if you have any aspirations towards either Windows or azure administration and it is quite different to other scripting languages as it works with an object pipeline (not piping text around like sh).

It will do your head in for a bit until it clicks, but it is worth it, and you can use it for making things easier day to day with small code snippets.

1 Like

blackcoffee
Me too I see that PowerShell worth to learn but I guess that you need an easy way to copy or backup, this will lead you to GUI tools, if you are using windows, tools like GoodSync, Teracopy, Gs Richcopy 360, and AllWaysync will be very helpful to you.

2 Likes

Thanks. Lost a little steam with the current world situation, but will check that out when I got round to it.

1 Like