小编Sam*_*Sam的帖子

Powershell日期类型无法找到

我正在尝试使用 PowerShell 连接virustotal API,代码来自virustotal 网站,我得到“无法找到类型 [System.Security.Cryptography.ProtectedData]”。错误信息。

代码如下

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!"
    }
}
Run Code Online (Sandbox Code Playgroud)

经过研究,我发现我需要使用 add-type 添加一些东西来解决这个问题。我需要添加什么建议?提前致谢。

powershell types

1
推荐指数
1
解决办法
3080
查看次数

标签 统计

powershell ×1

types ×1