Answer the question
In order to leave comments, you need to log in
Why is copying not performed when the script is executed by the scheduler?
Good day to all!
Tell me, there is a simple script. He makes a backup of the database and copies it over the network. If you execute the script manually, then everything is fine. But, the task in the Task Scheduler does not process copying. If you execute the script from the user specified in the scheduler, then the script also works from him. Where to dig?
Script:
$DB = "sa"
$CurrentDate = Get-Date -Format yyyy-MM-dd
$SQLPath = "SQLSERVER:\sql\S002\DEFAULT\DATABASES"
$BackupPath = "H:\backup\"
$BackupFile = "H:\backup\${CurrentDate}_$DB.bak"
$DestinationPath = "\\s015\bkup\"
import-module sqlps -DisableNameChecking
Backup-SqlDatabase -Path $SQLPath -Database $DB -BackupFile $BackupFile
Copy-Item $BackupFile $DestinationPath
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question