我创建了一个ps1文件,它将执行一些配置活动。我已经把那个文件上传到了Stroage帐户。现在,我已使用runbook创建了另一个自动化帐户,我要从该自动化runbook调用存储在存储帐户中的ps1文件。有人能帮帮忙吗。
发布于 2019-04-16 08:57:05
可以将.ps1文件下载到runbook temp文件夹,然后调用它。
存储在blob存储中的test.ps1文件,其内容如下:
param([string]$p1,[string]$p2)
Write-Output "***this is from a test ps1 file***"
Write-Output $p1
Write-Output $p2
代码如下:
#create the context to authenticate with azure storage
$context = New-AzureStorageContext -StorageAccountName your_storage_name -StorageAccountKey "your_storage_key"
#download the .ps1 file to runbook temp folder
Get-AzureStorageBlobContent -Container "your_blob_container" -Blob "test.ps1" -Destination $env:temp -Context $context | Out-Null
#execute the powershell
&"$env:temp\test.ps1" -p1 "my name is p1" -p2 "i'm p2"
结果是:
https://stackoverflow.com/questions/55687245
复制相似问题