【发布时间】:2020-10-03 21:05:13
【问题描述】:
我有一个 powershell 脚本,我需要按计划从 SQL 服务器执行该脚本。我认为这并不重要,但如果确实如此,脚本将发送命令以刷新 powerbi.com 数据集。我可以在本地和我的一台服务器上成功运行它,但是当我在另一台服务器上尝试时,我收到以下错误。
为了澄清,powershell 版本以及执行策略都匹配。我在这里列出了它们:
PS版 5.1.14409.1005
执行政策
Scope ExecutionPolicy
Machine Policy Undefined
User Policy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine RemoteSigned
我在其中一台服务器上遇到的错误如下:
Connect-PowerBIServiceAccount : Failed to populate environments in settings
At
DatasetRefresh_NoParam_Simple.ps1:9
char:1
+ Connect-PowerBIServiceAccount -Credential $myCred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...IServiceAccount:ConnectPowerBIServiceAccount) [Connect-Po
werBIServiceAccount], Exception
+ FullyQualifiedErrorId : Failed to populate environments in settings,Microsoft.PowerBI.Commands.Profile.ConnectPo
werBIServiceAccount
Invoke-PowerBIRestMethod : Login first with Login-PowerBIServiceAccount
At
DatasetRefresh_NoParam_Simple.ps1:19
char:1
+ Invoke-PowerBIRestMethod -Url $RefreshDSURL -Method Post -Body $MailF ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-PowerBIRestMethod], Exception
+ FullyQualifiedErrorId : System.Exception,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
我觉得我缺少一个服务器设置,但我使用管理员凭据登录并以管理员身份运行 powershell。任何帮助将不胜感激。
编辑
我尝试运行不同的脚本来显示我遇到的另一个错误。
\\BlahServerName\WorkSpace\PowerBI\BDW_Resources\Admin\DatasetRefresh_PS\DatasetRefresh_Param_onlyDataset.ps1 : File
\\BlahServerName\WorkSpace\PowerBI\BDW_Resources\Admin\DatasetRefresh_PS\DatasetRefresh_Param_onlyDataset.ps1 cannot be
loaded. The file
\\BlahServerName\WorkSpace\PowerBI\BDW_Resources\Admin\DatasetRefresh_PS\DatasetRefresh_Param_onlyDataset.ps1 is not
digitally signed. You cannot run this script on the current system. For more information about running scripts and
setting execution policy, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ \\BlahServerName\WorkSpace\PowerBI\BDW_Resources\Admin\DatasetRefresh_ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
这也是我得到的一个,它引导我查看执行策略,但如果我的两台服务器具有相同的策略设置,为什么我能够在一个服务器上执行而不能在另一个服务器上执行? (再一次,我以自己的身份登录并拥有管理员权限)
【问题讨论】:
-
您没有显示任何代码。
-
PowerShell 有 32 位和 64 位两种版本 - 每种版本都有自己的模块和设置集合。您使用的是正确的 PowerShell 环境吗?
-
@DougMaurer,我没有显示任何代码,因为我不确定它是否与我的问题相关。从 PowerShell 调用 PowerBI 数据集刷新是有据可查的,我的不包含任何额外内容。作为参考,您可以查看stackoverflow.com/questions/52697381/…,了解我的主要外观。
标签: sql-server powershell