Mirroring in Powershell script

  • I have a PowerShell script which runs a Full backup & transaction log backup in SQL 2012, copies the files to a remote server, restores the backups with norecovery, and configures mirroring. This works fine when I manually run it in Powershell, but fails in SQL Agent. The backups are created & restored, but the mirror config doesn't happen. The most likely explanation seems to be a permissions issue. What permissions are required to set up mirroring that the Agent Account doesn't typically have?

  • More information: When run under the context of the Agent Account user, the logs show an EXCEPTION_ACCESS_VIOLATION and generates a dump file. Here is an excerpt from the dump file:

    * BEGIN STACK DUMP:

    * 06/25/16 10:00:43 spid 95

    *

    *

    * Exception Address = 000007FEE43E5B9B Module(sqlmin+0000000000085B9B)

    * Exception Code = c0000005 EXCEPTION_ACCESS_VIOLATION

    * Access Violation occurred reading address 0000000000000028

    * Input Buffer 184 bytes -

    * ALTER DATABASE **** SET PARTNER = 'TCP://****:5022';;

    *

    *

    * MODULE BASE END SIZE

    * sqlservr 00000000FFC00000 00000000FFC3DFFF 0003e000

    * ntdll 0000000077900000 0000000077AA9FFF 001aa000

    * kernel32 00000000777E0000 00000000778FEFFF 0011f000

    * KERNELBASE 000007FEFD900000 000007FEFD969FFF 0006a000

    Again, the script works as expected when run in PowerShell ISE by my user account.

  • as a test create a credential with your account and add it as a proxy then assign proxt=y to the job and run it

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply