SQL2022 CTP using PowerShell to enable AlwaysOn

Copper Contributor

I'm trying to enable AlwaysOn using the following PowerShell script:

Enable-SqlAlwaysOn -ServerInstance $env:computername\$SQLServerInstance -NoServiceRestart


This works on SQL2019, but gives the following error on 2022:

Enable-SqlAlwaysOn : Could not obtain information about SQL Server Service 'MSSQL$SQL2022'.
At line:9 char:33
+ ... Enable-SqlAlwaysOn -ServerInstance $env:computername\$SQL ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (MSSQL$SQL2022:String) [Enable-SqlAlwaysOn], SqlPowerShellServiceException
+ FullyQualifiedErrorId : ServiceError,Microsoft.SqlServer.Management.PowerShell.Hadr.EnableSqlHADRServiceCommand


Is there a new version of the SQLServer module I need to get hold of?

2 Replies
To answer my own question, you have to use the prerelease version of the sqlservermodule Install-Module sqlserver -AllowPrerelease -Force -AllowClobber

@FGNicky Prerelease is not working