You don't need to modify the script at all. Just pass your hub's IP and backup destination as parameters. I chose to put the script into the same directory as my backup destination to keep it simple. I then scheduled a task to run "Powershell" periodically with arguments and startup directory.
Like @HAL9000 mentioned you don't need to change the script. You just need to add your hub's IP address and destination to the argument in task scheduler.
I created a directory for the script and a sub-directory for the backups. The reason for the sub-directory is I have another scheduled task that cleans out the files that are older than 30 days.
Here's the argument I'm using for deleting the old files.
Thanks @HAL9000 and @Vettester for trying to help me. I'm still struggling though.
I created script (ps1 file, did not change anything in it). Created a folder for it and to make it simple..I'm using same folder for the backup files.
Then created scheduler.
My config is:
powershell
.\Hubitat-Configuration-Backup.ps1 -HubHostname 192.168.86.45 -BackupDestination
C:\Users\myusername\Documents\Hubitat
I scheduled it and powershell briefly opens but nothing happens. I'm not getting bu file to folder. Am I doing something wrong here?
EDIT: I tried to run it manually from my laptop and script works. I tried same thing with my 24/7 pc and it does not work. It flashes some red text in powershell window before it closes. So this seems to be more of a user rights problem or some kind of powershell issue in that pc.
Ok.. I'm slowly getting there. Problem was because..
"Invoke-WebRequest : The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first
-launch configuration is not complete. Specify the UseBasicParsing parameter and try again. "
... so...opened IE and now script works at least when ran manually. Soon testing scheduler.
EDIT: and scheduler works now!!! Once again..thank you guys!! I really appreciate your help!