首页 > 解决方案 > PowerShell 错误:新对象:找不到“PlatformParameters”的重载和参数计数:“1”

问题描述

我正在尝试使用 Git 存储库 PowerBIPS 将 CSV 自动上传到 PowerBi。我似乎无法克服这个错误:

新对象:找不到“PlatformParameters”和参数计数的重载:“1”。

借助此处链接的文章(https://powerbi.microsoft.com/en-us/blog/using-a-power-bi-app-to-upload-csv-files-to-a-dataset/) ,我相信我已经找到了一个可行的解决方案来解决这个问题。但是,我遇到了一个我似乎无法弄清楚的错误。

我已经定制了原始文章中的代码以适应我目前的情况(在下面的代码中概述)。我可以一直运行代码,直到出现此错误的“将数据发送到 PowerBi 注释”。

我曾尝试参考 Git 文档来帮助解决此问题,但没有找到运气。我感觉它与连接到 PowerBi 的身份验证部分有关。

while ($true) {
    # Iterate each CSV file and send to PowerBI
    Get-ChildItem "$currentPath\CSVData" -Filter "*.csv" | % {
        $file = $_

        #Import csv and add column with filename
        $data = Import-Csv $file.FullName |
                select @{Label="File";Expression={$file.Name}}, *

        # Send data to PowerBI
        $data | Out-PowerBI -DataSetName "CSVSales" -TableName "Sales" -Types @{
            "Sales.OrderDate"   = "datetime";
            "Sales.SalesAmount" = "double";
            "Sales.Freight"     = "double"
        } -BatchSize 300 -Verbose

        # Archive the file
        Move-Item $file.FullName "$currentPath\CSVData\Archive\" -Force
    }

    Write-Output "Sleeping..."
    Sleep -Seconds 5
}
详细:获取身份验证令牌

VERBOSE:使用默认身份验证流程

新对象:找不到“PlatformParameters”和参数的重载
计数:“1”。
在 C:\Program Files\WindowsPowerShell\Modules\PowerBIPS\2.0.3.1\PowerBIPS.psm1:299 char:16
+ ... pltParams = 新对象 Microsoft.IdentityModel.Clients.ActiveDirector ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [New-Object], MethodException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

标签: powershellpowerbi

解决方案


推荐阅读