Ouvrez la console SQLPS et établissez une connexion aux réplicas principaux du groupe de disponibilité cible.
Target | Microsoft.SQLServer.2014.AlwaysOn.AvailabilityGroup |
Application | sqlps.exe |
WorkingDirectory | |
isRequireOutput | False |
Accessibility | Internal |
Enabled | True |
<ConsoleTask ID="Microsoft.SQLServer.2014.AlwaysOn.RunPowerShellForAvailabilityGroup" Accessibility="Internal" Target="AlwaysOnDisc!Microsoft.SQLServer.2014.AlwaysOn.AvailabilityGroup" RequireOutput="false" Category="MonitoringObject">
<Application>sqlps.exe</Application>
<Parameters>
<Parameter>-NoExit</Parameter>
<Parameter>"&{ New-Variable -Name pr -Value '$Target/Property[Type="AlwaysOnDisc!Microsoft.SQLServer.2014.AlwaysOn.AvailabilityGroup"]/PrimaryReplicaServerName$'; function p{ param($v) if ($v -ilike '*\*') { return $v } else { return '{0}\DEFAULT' -f $v } }; if (-Not [string]::IsNullOrEmpty($pr)) { $p = '{0}' -f (p($pr)); cd SQL\$p\AvailabilityGroups\; cd '$Target/Property[Type="System!System.Entity"]/DisplayName$\' -WarningAction SilentlyContinue; } else { Write-Host 'There is no primary replica for this Availability Group' }}"</Parameter>
</Parameters>
<WorkingDirectory/>
</ConsoleTask>