PowerShell中的AlwaysEncrypted数据加密失败 [英] AlwaysEncrypted Data Encryption failing in PowerShell

查看:90
本文介绍了PowerShell中的AlwaysEncrypted数据加密失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用AlwaysEncrypted加密多个列,尝试使用PowerShell应用加密,并且失败并显示以下错误消息:

I'm trying to encrypt multiple columns using AlwaysEncrypted, trying to apply the encryption using PowerShell and it is failing with the below error message :

Set-SqlColumnEncryption:'Microsoft.SqlServer.Management.AlwaysEncrypted.Types.AlwaysEncryptedManager'的类型初始值设定项引发异常。

Set-SqlColumnEncryption : The type initializer for 'Microsoft.SqlServer.Management.AlwaysEncrypted.Types.AlwaysEncryptedManager' threw an exception.

提供异常的实际代码行是:

The actual line of code where is is giving exception is :

Set-SqlColumnEncryption -ColumnEncryptionSettings $ encryptionChanges -InputObject $ smoDatabase

Set-SqlColumnEncryption -ColumnEncryptionSettings $encryptionChanges -InputObject $smoDatabase

进一步查看错误,我发现了以下异常:

Further looking into the error, I've found the below exception :

System.TypeInitializationException:'Microsoft.SqlServer.Management.AlwaysEncrypted.Types.AlwaysEncryptedManager'的类型初始值设定项引发异常。 ---> System.Reflection.TargetInvocationException: 

 抛出了异常。                      调用的目标。 ---> System.TypeInitializationException:'Microsoft.SqlServer.Management.AlwaysEncrypted.Management.AlwaysEncryptedManagement'
的类型初始值设定项引发异常。 ---> System.IO.FileNotFoundException:无法 

                       加载文件或程序集'System.Net.Http,Version = 4.2.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一。系统找不到指定的文件。

System.TypeInitializationException: The type initializer for 'Microsoft.SqlServer.Management.AlwaysEncrypted.Types.AlwaysEncryptedManager' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the 
                        target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Microsoft.SqlServer.Management.AlwaysEncrypted.Management.AlwaysEncryptedManagement' threw an exception. ---> System.IO.FileNotFoundException: Could not 
                        load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

我正在运行SQL Server 2016 Enterprise,PS Version 5.1,SQLPS版本  21.1.18068。

I'm running SQL Server 2016 Enterprise, PS Version 5.1, SQLPS version 21.1.18068.

不确定我在这里缺少什么。任何帮助都将受到高度赞赏。

Not sure what am I missing here. Any help will be highly appreciated.

推荐答案

Hi Anindya1.R,



SQLPS不再更新。 SqlServer模块包含新的cmdlet以支持最新的SQL功能。你可以导入SqlServer模块然后再试一次吗?这是一个例子。

Hi Anindya1.R,

SQLPS is no longer being updated. The SqlServer module includes new cmdlets to support the latest SQL features. Could you import the SqlServer module and try again? Here is an example.

# Import the SqlServer module.
Import-Module "SqlServer"

# Connect to your database.


serverName ="< server name>"
serverName = "<server name>"


databaseName =" ;<数据库名称>"
databaseName = "<database name>"


这篇关于PowerShell中的AlwaysEncrypted数据加密失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆