【发布时间】:2019-04-16 02:05:08
【问题描述】:
我一般都喜欢 powershell,但引用程序集总是很困难。
使用 powershell 6.2。我需要创建一个存在于 System.Security.Cryptography.Csp.dll 中的对象。该 dll 位于 C:\Program Files\PowerShell\6\ref 中。
这是使用垃圾参数创建的有问题的对象:New-Object PasswordDeriveBytes($null, $null, 'SHA1', 2)
以下是我尝试添加对带有错误的加密 dll 的引用:
-
Add-Type -AssemblyName *System.Security.Cryptography.Csp*# 找不到类型 -
Add-Type -AssemblyName System.Security.Cryptography.Csp.dll# 找不到路径'C:\pathToMyScript\System.Security.Cryptography.Csp.dll',因为它不存在 -
Add-Type -Path 'System.Security.Cryptography.Csp.dll'# 与上述相同的错误 -
Add-Type -Path 'C:\Program Files\PowerShell\6\ref\System.Security.Cryptography.Csp.dll'# 找不到类型 [PasswordDeriveBytes]:验证是否加载了包含此类型的程序集(Add-Type 没有错误)
如何简单地添加对使用 powershell 安装的程序集的引用?再多看其他示例也无济于事,似乎它们通常是上述变体之一。
【问题讨论】:
-
[PasswordDeriveBytes]->[System.Security.Cryptography.PasswordDeriveBytes]
标签: powershell