I have a SQL Server 2014 instance job that runs nightly that moves backups from the local drive to a network drive. I wrote it using PowerShell.
$mypath = $('F:\Backup\CRMDB01$CRMDB012014\Prod\Full\')
$mydestination = '\\stagingshare\fromprod\'
$myfile = gci $mypath | sort LastWriteTime | select -last 1
copy-item -path ($mypath + $myfile) -destination $mydestination
The job is failing with "reason: line(1): Syntax Error". I have it set to "Run as:" proxy_1.
proxy_1 has a credentialed name next to it that has access to the share. I don't have any principals selected.
What am I missing?
$()
out from around your first line, so should just be$myPath = 'F:\Backup\CRMDB01$CRMDB012014\Prod\Full\'