PS script to move back up files

Hi All,

I have this PowerShell script that moves back up files from the local drive to remote storage on the same network.   I need assistance adding admin credentials in the script for the remote drive and also schedule it via task scheduler so that it can run without user intervention.  Any suggestions would be appreciated.

Thanks!

get-childitem -Path "D:\Backup" |
    where-object {$_.LastWriteTime -lt (get-date).AddDays(-30)} | 
    move-item -destination "Z:\BAK" 
   

September 3rd, 2015 8:08am

Hi,

If you schedule the script to run as an account that has appropriate rights, you don't need to adjust the script.

What problems are you having with scheduling?

Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 8:10am

Thanks for the response. I'm not sure why but when I schedule it via task scheduler it won't run.  Are there certain arguments that I should pass?
September 3rd, 2015 8:33am

How do you currently have it set up?

This is what I use:

General -

Set the proper user, tick 'Run whether user is logged on or not', and tick 'Run with highest privileges'.

Actions -

Action: Start a program

Program/Script: full path to powershell.exe

Add arguments: -File C:\path\to\script.ps1

Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 8:38am

Great I think I was able to get the task to run however how can I overwrite existing files with powershell?

I am at a point now where the script is failing because I stopped it in the middle of moving files so I need to be able to overwrite them. 

Appreciate your assistance. 

September 8th, 2015 1:16pm

You can use the -Force parameter:

http://ss64.com/ps/move-item.html

Please start a new thread if you have further issues. We try to keep threads to a single topic.

Free Windows Admin Tool Kit Click here and download it now
September 8th, 2015 1:20pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics