File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ # # This needs to be run as a file available to the agent service
2
+
3
+ # # as a SQLCMD step
4
+
5
+ # # powershell.exe 'path to file'
6
+
7
+ Write-Output " Starting Copy of XXXX database from SourceServerName to DestServerName"
8
+
9
+ try {
10
+ $params = @ {
11
+ Source = ' '
12
+ Destination = ' '
13
+ Database = ' '
14
+ BackupRestore = $true
15
+ NetworkShare = ' '
16
+ WithReplace = $true
17
+ EnableException = $true
18
+ Verbose = $true
19
+ }
20
+ $output = Copy-DbaDatabase @Params
21
+ }
22
+ Catch
23
+ {
24
+ $CopyError = $error [0 .. 5 ] | fl - force
25
+ $CopyError = $CopyError | OUt-String
26
+ Write-Error $CopyError
27
+
28
+ [System.Environment ]::Exit (1 )
29
+ }
30
+ if ($output.Status = ' Failed' ) {
31
+ $CopyError = $error [0 .. 5 ] | fl - force
32
+ $CopyError = $CopyError | OUt-String
33
+ Write-Error $CopyError
34
+ [System.Environment ]::Exit (1 )
35
+ }
You can’t perform that action at this time.
0 commit comments