我正在尝试创建一个脚本,通过 Powershell Runbook 为 SSAS 创建自动分区,但是每当我尝试读取 xmla 文件时,都会出现以下错误:
我调用它的代码如下:
$StorageAccount = Get-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName
$blob = Get-AzureStorageBlob -Context $StorageAccount.Context -Container "Database name" -Blob "CreateNewPartition.xmla"
$file = $blob.ICloudBlob.DownloadText()
Invoke-ASCmd `
-Database $AnalysisServiceDatabase `
-InputFile $file `
-server $AnalysisServiceServer
使用以下代码时:
$memStream = New-Object System.IO.MemoryStream
$blob.ICloudBlob.DownloadToStream($memStream)
$readStream = New-Object System.IO.StreamReader($memStream, [System.Text.Encoding]::Unicode)
$memStream.Position = 0
$file = ($readStream.ReadToEnd() -replace "`0",'' | ConvertFrom-Json)
在尝试此代码时:
$byteArray = New-Object Byte[] $blob.Length
$file = $blob.ICloudBlob.DownloadToByteArray($byteArray, 0)