首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何使用Runbook执行存储在Azure存储中的Powershell

如何使用Runbook执行存储在Azure存储中的Powershell
EN

Stack Overflow用户
提问于 2019-04-15 18:32:08
回答 1查看 248关注 0票数 0

我创建了一个ps1文件,它将执行一些配置活动。我已经把那个文件上传到了Stroage帐户。现在,我已使用runbook创建了另一个自动化帐户,我要从该自动化runbook调用存储在存储帐户中的ps1文件。有人能帮帮忙吗。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-16 08:57:05

可以将.ps1文件下载到runbook temp文件夹,然后调用它。

存储在blob存储中的test.ps1文件,其内容如下:

代码语言:javascript
复制
param([string]$p1,[string]$p2)

Write-Output "***this is from a test ps1 file***"
Write-Output $p1
Write-Output $p2

代码如下:

代码语言:javascript
复制
    #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"

结果是:

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55687245

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档