先ほどのログイン自動化に続いて、Azure PowerShell 4.4.0 以降で使える便利な TIPS をもう一つ。 各コマンドレットに AzureRmContext というオプションが追加されて、PSJob 内に認証情報を渡せるようになっています。 Start-Job { # ArgumentList で渡した Context を引数 ($ctx) として使用して、 param ($ctx) # 並列実行したいコマンドを $ctx の認証情報で実行 Get-AzureRMVM -AzureRmContext $ctx } -ArgumentList (Get-AzureRmContext) # ジョブの一覧を表示 Get-Job Id Name PSJobTypeName State HasMoreData Location Command -- ---- -------------