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
Author
Message
Posted Friday, April 18, 2014 8:23 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, July 21, 2014 8:19 AM
Points: 193, Visits: 917
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
-Script 

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:

SQLSERVER:\SQL\MyComputer\MyInstance\Databases\AdventureWorks2008R2



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


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 8:50 AM
Points: 6,189, Visits: 13,338
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