Powershell 完成Azure StorSimple虚拟设备的设备设置在自动化运行手册中失败

Powershell 完成Azure StorSimple虚拟设备的设备设置在自动化运行手册中失败,powershell,azure,azure-powershell,azure-automation,Powershell,Azure,Azure Powershell,Azure Automation,我正在使用Runbook automation创建Azure Storsimple虚拟设备和其中的存储容器。创建设备后,我需要完成设备设置(设置快照管理器密码、管理员密码和服务加密密钥) 如果我在我的powershell中运行,这段代码工作得非常好。但是如果我在Automation runbook中运行它,那么设备就会被创建,但是配置步骤本身就失败了 你的错误是什么?另外,当您说它在PowerShell中运行良好时,您是将其作为PowerShell工作流还是作为PowerShell脚本进行测试?

我正在使用Runbook automation创建Azure Storsimple虚拟设备和其中的存储容器。创建设备后,我需要完成设备设置(设置快照管理器密码、管理员密码和服务加密密钥)


如果我在我的powershell中运行,这段代码工作得非常好。但是如果我在Automation runbook中运行它,那么设备就会被创建,但是配置步骤本身就失败了

你的错误是什么?另外,当您说它在PowerShell中运行良好时,您是将其作为PowerShell工作流还是作为PowerShell脚本进行测试?Azure Automation运行PowerShell工作流,因此您还需要使用PowerShell工作流在本地进行测试。@Joe当我将其作为PowerShell工作流运行时,它工作得非常完美。在runbook中运行时,配置步骤失败,没有输出。我尝试打印输出($configoutput),但它仍然不打印任何内容
$NewDeviceJob=New-AzureStorSimpleVirtualDevice -VirtualDeviceName $VirtualDeviceName -VirtualNetworkName $VirtualNetworkName -StorageAccountName  $StorageAccount -SubNetName $SubNetName 

#waiting for storsimple device creation
$loopvariable=$true 
while($loopvariable -eq $true)
{
    Start-Sleep -s 10
    $DeviceCreationOutput=Get-AzureStorSimpleJob -InstanceId ($NewDeviceJob.ToString())
    if($DeviceCreationOutput.Status -ne "Running"){
        $loopvariable=$false 
    }


}

$status=$DeviceCreationOutput.Status

if($Status -ne "Completed")
{
    Write-Output "Virtual Appliance Creation $Status "
    Exit
}

Write-Output "Virtual Device Created "

#waitforthe Device To get Online

$loopvariable=$true
while($loopvariable -eq $true){
   Start-Sleep -s 5
   $VirtualDevice=  Get-AzureStorSimpleDevice -DeviceName $VirtualDeviceName
   if($VirtualDevice.Status -eq "Online"){
        $loopVariable=$false
    }
 } 

Start-Sleep -s 10
 $configoutput=Set-AzureStorSimpleVirtualDevice -DeviceName $VirtualDeviceName -SecretKey $VDServiceEncryptionKey -AdministratorPassword $VDDeviceAdministratorPassword -SnapshotManagerPassword $VDSnapShotManagerPassword
if($configoutput.TaskStatus -eq "Completed"){
    Write-Output "Configuration of Virtual Device Successful"
}
else
{
Write-Output "configuration of virtual device failed"
}