用于在Azure上刷新表格多维数据集的PowerShell脚本
我需要设置powershell脚本,以便在Azure、Microsoft SQL Analysis Server(版本15.0.0.52)上刷新表格模型多维数据集。 我编写了这个解决方案,但每次执行时都会出现相同的错误用于在Azure上刷新表格多维数据集的PowerShell脚本,powershell,azure,ssas,Powershell,Azure,Ssas,我需要设置powershell脚本,以便在Azure、Microsoft SQL Analysis Server(版本15.0.0.52)上刷新表格模型多维数据集。 我编写了这个解决方案,但每次执行时都会出现相同的错误 # PowerShell code # Connect to a connection to get TenantId and SubscriptionId $Connection = Get-AutomationConnection -Name "AzureRunAsC
# PowerShell code
# Connect to a connection to get TenantId and SubscriptionId
$Connection = Get-AutomationConnection -Name "AzureRunAsConnection"
$TenantId = $Connection.TenantId
$SubscriptionId = $Connection.SubscriptionId
# Get the service principal credentials connected to the automation account.
$null = $SPCredential = Get-AutomationPSCredential -Name "Samcred"
# Login to Azure ($null is to prevent output, since Out-Null doesn't work in Azure)
Write-Output "Login to Azure using automation account 'Samcred'."
$null = Login-AzureRmAccount -TenantId $TenantId -SubscriptionId $SubscriptionId -Credential $SPCredential
# Select the correct subscription
Write-Output "Selecting subscription '$($SubscriptionId)'."
$null = Select-AzureRmSubscription -SubscriptionID $SubscriptionId
# Get variable values
$DatabaseName = Get-AutomationVariable -Name 'DatabaseName'
$AnalysisServerName = Get-AutomationVariable -Name 'AnalysisServerName'
# Show info before processing (for testing/logging purpose only)
Write-Output "Processing $($DatabaseName) on $($AnalysisServerName)"
#Process database
$null = Invoke-ProcessASDatabase -databasename $DatabaseName -server $AnalysisServerName -RefreshType "Full" -Credential $SPCredential
# Show done when finished (for testing/logging purpose only)
Write-Output "Done"
错误包括:
Login to Azure using automation account 'Samcred'.
Login-AzureRmAccount : unknown_user_type: Unknown User Type
At line:12 char:9
+ $null = Login-AzureRmAccount -TenantId $TenantId -SubscriptionId $Sub ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Add-AzureRmAccount], AadAuthenticationFailedException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.AddAzureRMAccountCommand
Selecting subscription 'fb3456-56c2-40a2-aae6-9eeace345678'.
Select-AzureRmSubscription : Run Login-AzureRmAccount to login.
At line:16 char:9
+ $null = Select-AzureRmSubscription -SubscriptionID $SubscriptionId
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Set-AzureRmContext], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.Azure.Commands.Profile.SetAzureRMContextCommand
Processing TabCube on asazure://westus.asazure.windows.net/dex:rw
Invoke-ProcessASDatabase : Exception has been thrown by the target of an invocation.
At line:26 char:9
+ $null = Invoke-ProcessASDatabase -databasename $DatabaseName -server ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-ProcessASDatabase], TargetInvocationException
+ FullyQualifiedErrorId :
System.Reflection.TargetInvocationException,Microsoft.AnalysisServices.PowerShell.Cmdlets.ProcessASDatabase
Done
有什么建议吗
$null = $SPCredential = Get-AutomationPSCredential -Name "Samcred"
如果您使用Microsoft帐户登录Azure,您将获得错误日志。在Azure runbook中,您可以使用服务主体登录,而不是使用帐户。更改脚本,如下所示:
$connectionName = "AzureRunAsConnection"
try
{
# Get the connection "AzureRunAsConnection "
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName
"Logging in to Azure..."
Add-AzureRmAccount `
-ServicePrincipal `
-TenantId $servicePrincipalConnection.TenantId `
-ApplicationId $servicePrincipalConnection.ApplicationId `
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
}
catch {
if (!$servicePrincipalConnection)
{
$ErrorMessage = "Connection $connectionName not found."
throw $ErrorMessage
} else{
Write-Error -Message $_.Exception
throw $_.Exception
}
}
您使用的凭据是Microsoft帐户吗?显然有一些限制,在GitHub上看到了:还有,看到了。是的,但现在有了新问题:调用进程数据库:身份验证失败:当用户界面不可用时,需要用户ID和密码。第50行字符:9+$null=调用ProcessASDatabase-databasename$databasename-server…+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CategoryInfo:NotSpecified:(:)[Invoke ProcessASDatabase],ArgumentException+FullyQualifiedErrorId:System.ArgumentException,Microsoft.AnalysisServices.PowerShell.cmdlet.ProcessASDatabase已完成