因此,首先我对 PowerShell 相当陌生(在去年)我现在了解了很多,但是现在 API 调用对我来说是新的。
我已经弄清楚如何使用不需要任何值的 Web 调用进行 API 调用。或者那些不需要值数组的。如:$BSSPrincipalManagementWSP.ReadAccount("1_V4-0119341")
返回我想要的一切。但是,如果我遇到像 $BSSPrincipalManagementWSP.UpdateAccountValues 的网络调用这样的奇特事物,第一个变量是帐户外部 ID,但所需的第二个变量是数组中的 accountValues。
我已经尝试过这样的事情来完成它:
function Update-AccountValues
(
[string]$accountExternalId,
[array]$accountValues = @(Import-Csv -Path $ImportPath)
)
{
$accountValues
$BSSPrincipalManagementWSP.UpdateAccountValues($accountExternalId, $accountValues)
}
Update-AccountValues "1_V4-0119341"
但我收到以下错误:
Cannot convert argument "accountValues", with value: "System.Object[]", for "UpdateAccountValues" to type "BSSPrincipalManagementNS.AccountValue[]": "Cannot convert value
"@{Key=ScreenSaverTimeoutMinutes; Value=60}" to type "BSSPrincipalManagementNS.AccountValue". Error: "Cannot convert the "@{Key=ScreenSaverTimeoutMinutes; Value=60}" value of type
"System.Management.Automation.PSCustomObject" to type "BSSPrincipalManagementNS.AccountValue".""
At C:\Users\Matt Bergeron\AppData\Local\Temp\ff88f967-9d7c-4f6f-a424-212298a69655.ps1:61 char:2
+ $BSSPrincipalManagementWSP.UpdateAccountValues($accountExternalId, $accountValu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
我以为我按照它的要求传递了“一个 accountValue 对象数组”。
CSV 文件中的所有内容都是 2 列,其中 1 列列为键,另一列列为值。它们的名称与 OSS/BSS CHM 文件中的名称完全相同。
谁能告诉我哪里出错了?任何帮助将非常感激。