Powershell日期类型无法找到 [英] Powershell date type unable to find
问题描述
我正在尝试使用 PowerShell 连接virustotal API,代码来自virustotal 网站,我收到无法找到类型 [System.Security.Cryptography.ProtectedData]".错误信息.
I am trying to use PowerShell to connect virustotal API, the code is from virustotal website and I got "Unable to find type [System.Security.Cryptography.ProtectedData]." error message.
代码如下
function Get-VTApiKey {
[CmdletBinding()]
Param([String] $vtFileLocation = $(Join-Path $env:APPDATA 'virustotal.bin'))
if (Test-Path $vtfileLocation) {
$protected = [System.IO.File]::ReadAllBytes($vtfileLocation)
$rawKey = [System.Security.Cryptography.ProtectedData]::Unprotect($protected, $null, [System.Security.Cryptography.DataProtectionScope]::CurrentUser)
return [System.Text.Encoding]::Unicode.GetString($rawKey)
} else {
throw "Call Set-VTApiKey first!"
}
}
经过研究,我发现我需要使用 add-type 添加一些东西来解决这个问题.我需要添加什么建议?提前致谢.
after research I find I need to use add-type to add something to solve this. Any suggestion what I need to add? Thanks in advance.
推荐答案
MSDN 文档页面 将程序集列为System.Security
.所以你需要:
The MSDN documentation page lists the assembly as System.Security
. So you need to:
Add-Type -AssemblyName System.Security
您可能还需要考虑使用 System.Core
以获得其他一些密码学功能(谷歌搜索列出了它们)
You may also want to consider System.Core
for some of the other Cryptography features (google search lists them)
Add-Type -AssemblyName System.Core
这篇关于Powershell日期类型无法找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!