SQL Server Powershell - The term 'New-SqlColumnEncryptionKey' is not recognized - trying to create Column Encryption Key

pgccezyw  于 2023-10-15  发布在  Shell
关注(0)|答案(1)|浏览(114)

I'm using Powershell 7.0.3. Having connected to azure (via connect-AzAccount) I can list my Column Master Keys:

Get-SqlColumnMasterKey -InputObject $database

Name
----
MYDB_CMK
MYDB_CMK2

On attempting to create a Column Encryption Key..

New-SqlColumnEncryptionKey -Name "MYDB_CEK" -InputObject $database -ColumnMasterKey "MYDB_CMK"

I get the following error:

New-SqlColumnEncryptionKey: The term 'New-SqlColumnEncryptionKey' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

As far as I'm aware the commands Get-SqlColumnMasterKey and New-SqlColumnEncryptionKey should be in the same module, loaded via

Import-Module "SqlServer"

What have I missed?

but5z9lq

but5z9lq1#

2023 Update

The SqlServer module in Powershell 7.x (v 22+) now supports all of the Sql Column Encryption cmdlets as per the docs here:

https://learn.microsoft.com/en-us/powershell/module/sqlserver/new-sqlcolumnencryptionkey?view=sqlserver-ps

Original answer

Yes, it is a part of SqlServer module but, it is only supported in Powershell 5:

相关问题