SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 SQL Server Administration (2012)
 Powershell script to move backups
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

4 Posts

Posted - 10/30/2013 :  15:47:34  Show Profile  Reply with Quote

I am attempting to set up a job where nightly backups are moved off the local server onto a different server; the job fails however at the second step where I have a powershell script run. The script is:

powershell.exe -NoLogo -NoProfile -Command "&'C:\scripts\sql\copy_to_fileserver.ps1' 'companydb.bak'"

I am not sure whether the script is in error or if there is something set wrong in the permissions to allow the move. Any ideas where I should be looking?

James K
Flowing Fount of Yak Knowledge

3865 Posts

Posted - 10/30/2013 :  15:57:55  Show Profile  Reply with Quote
Is it giving you any error message at all?

If this is the first time you are running a powershell script, you would need to set the execution policy. By default it is Restricted, which will prevent scripts in files from being run. http://technet.microsoft.com/en-us/library/hh849812.aspx

If that is not the case, see if you are able to run the script (C:\scripts\sql\copy_to_fileserver.ps1) from a powershell interactive window - which will tell you if the script is in error.
Go to Top of Page

Starting Member

4 Posts

Posted - 10/30/2013 :  17:25:56  Show Profile  Reply with Quote
We run AllSigned execution policy on this machine. Running in powershell, both the scripts run, but nothing happens -no files are transferred and no error messages. Since this script is running as a SQLAgent job, would there be an issue with permissions on the destination directory?
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.16 seconds. Powered By: Snitz Forums 2000