Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无提示下载PBIX的PowerShell脚本_Powershell_Powerbi - Fatal编程技术网

无提示下载PBIX的PowerShell脚本

无提示下载PBIX的PowerShell脚本,powershell,powerbi,Powershell,Powerbi,我正在使用以下代码从工作区自动导出PBIX: Login-PowerBIServiceAccount Export-PowerBIReport -WorkspaceId xyz-abc-pqr-lmn-rtp -Id ewrew-werwe-sd-sss-ssssss -OutFile .\abc.pbix 它确实会导出PBIX,但会提示一个对话框,我必须在其中确认我的用户名。我想摆脱这个对话框,因为这将是一个自动化的实用程序。我尝试了以下方法: $password = 'password'

我正在使用以下代码从工作区自动导出PBIX:

Login-PowerBIServiceAccount 
Export-PowerBIReport -WorkspaceId xyz-abc-pqr-lmn-rtp -Id ewrew-werwe-sd-sss-ssssss -OutFile .\abc.pbix
它确实会导出PBIX,但会提示一个对话框,我必须在其中确认我的用户名。我想摆脱这个对话框,因为这将是一个自动化的实用程序。我尝试了以下方法:

$password = 'password' | ConvertTo-SecureString -asPlainText -Force
$username = 'abc@pqr.com'
$credential = New-Object System.Management.Automation.PSCredential($username, $password)
Connect-PowerBIServiceAccount -Credential $credential
然而,上述代码给了我以下问题:

Connect-PowerBIServiceAccount : Failed to get ADAL token: Unhandled Exception: System.AggregateException: One or more errors occurred

关于这方面的任何线索。

如果以交互方式执行,会发生什么情况:
连接PowerBIServiceAccount-ServicePrincipal-Credential(获取凭据)
需要考虑的事项:帐户MFA是否已启用?您是否通过代理访问internet?是的!该帐户已启用MFA。您提供的代码确实要求输入用户名和密码,但它无法进行身份验证,并给出错误“登录PowerBIServiceAccount:无法获取ADAL令牌”“我不是通过代理访问internet。考虑到所有这些因素,我如何使其工作?好的,如果是MFA,可能会将该帐户添加到条件接收策略旁路和/或运行该帐户的IP。和/或如果您使用的帐户具有永久分配的GA等高权限(糟糕的做法!),请使用具有所需权限的帐户。也许你可以自己搜索MFA的PowerBI报告或最佳实践报告帐户的权限(我个人对PowerBI一无所知),事实上我就是这么做的。看起来像是。这里有一个页面讨论了一个解决方案和一个解决方案(符合我的建议)