# use sql named instance in a powershell script

**URL:** <https://forums.powershell.org/t/use-sql-named-instance-in-a-powershell-script/14835>\
**Category:** PowerShell Help\
**Created:** [August 20, 2020, 6:42pm UTC](https://forums.powershell.org/t/use-sql-named-instance-in-a-powershell-script/14835 "2020-08-20T18:42:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![theoneakta](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@theoneakta](https://forums.powershell.org/u/theoneakta)\
**Post date:** [August 20, 2020, 6:42pm UTC](https://forums.powershell.org/t/use-sql-named-instance-in-a-powershell-script/14835/1 "2020-08-20T18:42:33Z")

</div>

Hi

&nbsp;

I am trying to use:

&nbsp;

Set-SqlAvailabilityReplica -AvailabilityMode “SynchronousCommit” -FailoverMode “Manual” ` -Path "SQLSERVER:\SQL\xxx\DEFAULT\AvailabilityGroups\xxx\AvailabilityReplicas"

&nbsp;

With an instance name meaning at the end sqlserver\instancename

&nbsp;

Every attempt to put quotes, or encode the value or create a variable wont work

&nbsp;

Anyone can help me find out how i can do this?

&nbsp;

With a sql server no instance it works

&nbsp;

Thanks

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [August 21, 2020, 4:32am UTC](https://forums.powershell.org/t/use-sql-named-instance-in-a-powershell-script/14835/2 "2020-08-21T04:32:38Z")

</div>

Take a look at this:

> **[A Month of SQLPS: Managing Availability Group Replicas](https://www.mikefal.net/2015/10/20/a-month-of-sqlps-managing-availability-group-replicas/)**
>
> Now that we understand how to prepare our machines for an Availability Group, we can go about the business of creating an Availability Group. This can be fairly involved, but the SQLPS cmdlets can …

> Note the path we use, not to be confused with the path of the SQL Server instance. This path should be within the context of the primary node for the AG. Running this command will create the replica.

---

<div class="post-metadata">

**Author:** ![theoneakta](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@theoneakta](https://forums.powershell.org/u/theoneakta)\
**Post date:** [August 28, 2020, 11:33am UTC](https://forums.powershell.org/t/use-sql-named-instance-in-a-powershell-script/14835/3 "2020-08-28T11:33:32Z")

</div>

[quote quote=251612]Take a look at this:

> [A Month of SQLPS: Managing Availability Group Replicas](https://www.mikefal.net/2015/10/20/a-month-of-sqlps-managing-availability-group-replicas/)

\<iframe width="600" height="264" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" title="“A Month of SQLPS: Managing Availability Group Replicas” — Art of the DBA" src="https://www.mikefal.net/2015/10/20/a-month-of-sqlps-managing-availability-group-replicas/embed/#?secret=lPGncFHb4l" data-secret="lPGncFHb4l" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" data-mce-fragment="1"\>\</iframe\>

> Note the path we use, not to be confused with the path of the SQL Server instance. This path should be within the context of the primary node for the AG. Running this command will create the replica.

[/quote]

Thanks. it guided me to the right place

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:28pm UTC](https://forums.powershell.org/t/use-sql-named-instance-in-a-powershell-script/14835/4 "2024-05-16T20:28:58Z")

</div>


