Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Powershell and Alwayson Question Expand / Collapse
Posted Friday, April 18, 2014 8:23 AM


Group: General Forum Members
Last Login: Tuesday, August 12, 2014 12:24 PM
Points: 193, Visits: 918
I'm trying to join an availability group to a cluster node using the command below in powershell. I receive the error also shown below. When I run sp_who2 in management studio I can see that the session of powershell that is running is not in the master database. How do I force this command to be executed within the context of master within powershell?

set-location sqlserver:\sql\$SecondaryServer\default
Join-SqlAvailabilityGroup -Path SQLServer:\sql\$SecondaryServer\default -Name $groupname
Join-SqlAvailabilityGroup : Availability-group DDL operations are permitted only when you are using the master database. Run the USE MASTER command, and retry your availability-group DDL command.
At line:2 char:26
+ Join-SqlAvailabilityGroup <<<< -Path SQLServer:\sql\$SecondaryServer\default -Name $groupname
+ CategoryInfo : InvalidOperation: (:) [Join-SqlAvailabilityGroup], SqlException
+ FullyQualifiedErrorId : ExecutionFailed,Microsoft.SqlServer.Management.PowerShell.Hadr.JoinSqlAvailabilityGroupCommand

Post #1563047
Posted Friday, April 18, 2014 1:08 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, April 30, 2014 6:38 AM
Points: 33, Visits: 65
If you append

to the end of the Join-SqlAvailabilityGroup command it should script it out for you. This could provide additional insight as to where it is trying to do this.

Also to set a database I believe it would look similar to this:


- Tony Sweet
Post #1563148
Posted Sunday, April 20, 2014 1:32 PM



Group: General Forum Members
Last Login: Today @ 1:26 PM
Points: 6,300, Visits: 13,580
have you first added the new replica to the AlwaysOn group?


"Ya can't make an omelette without breaking just a few eggs"
Post #1563355
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse