{"id":4138,"date":"2018-01-09T22:56:04","date_gmt":"2018-01-09T13:56:04","guid":{"rendered":"https:\/\/www.syuheiuda.com\/?p=4138"},"modified":"2018-01-09T23:04:41","modified_gmt":"2018-01-09T14:04:41","slug":"azure-powershell-%e3%81%ae%e3%82%b8%e3%83%a7%e3%83%96%e5%ae%9f%e8%a1%8c","status":"publish","type":"post","link":"https:\/\/www.syuheiuda.com\/?p=4138","title":{"rendered":"Azure PowerShell \u306e\u30b8\u30e7\u30d6\u5b9f\u884c"},"content":{"rendered":"<p>\u5148\u307b\u3069\u306e<a href=\"https:\/\/www.syuheiuda.com\/?p=4135\">\u30ed\u30b0\u30a4\u30f3\u81ea\u52d5\u5316<\/a>\u306b\u7d9a\u3044\u3066\u3001<a href=\"https:\/\/github.com\/Azure\/azure-powershell\/releases\/tag\/v4.4.0-September2017\">Azure PowerShell 4.4.0<\/a> \u4ee5\u964d\u3067\u4f7f\u3048\u308b\u4fbf\u5229\u306a TIPS \u3092\u3082\u3046\u4e00\u3064\u3002<\/p>\n<p>\u5404\u30b3\u30de\u30f3\u30c9\u30ec\u30c3\u30c8\u306b AzureRmContext \u3068\u3044\u3046\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u8ffd\u52a0\u3055\u308c\u3066\u3001PSJob \u5185\u306b\u8a8d\u8a3c\u60c5\u5831\u3092\u6e21\u305b\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">Start-Job {\r\n\r\n   # ArgumentList \u3067\u6e21\u3057\u305f Context \u3092\u5f15\u6570 ($ctx) \u3068\u3057\u3066\u4f7f\u7528\u3057\u3066\u3001\r\n    param ($ctx)\r\n\r\n    # \u4e26\u5217\u5b9f\u884c\u3057\u305f\u3044\u30b3\u30de\u30f3\u30c9\u3092 $ctx \u306e\u8a8d\u8a3c\u60c5\u5831\u3067\u5b9f\u884c\r\n    Get-AzureRMVM -AzureRmContext $ctx\r\n\r\n} -ArgumentList (Get-AzureRmContext)\r\n\r\n\r\n# \u30b8\u30e7\u30d6\u306e\u4e00\u89a7\u3092\u8868\u793a\r\nGet-Job\r\n\r\nId     Name            PSJobTypeName   State         HasMoreData     Location             Command\r\n--     ----            -------------   -----         -----------     --------             -------\r\n1      Job1            BackgroundJob   Completed     True            localhost            ...\r\n\r\n\r\n# \u30b8\u30e7\u30d6\u306e\u5b9f\u884c\u7d50\u679c\u3092\u8868\u793a (\u2191\u3067 State \u304c Running \u306e\u5834\u5408\u306f\u5f85\u3064\u3079\u3057)\r\nReceive-Job 1 # Job ID\r\n\r\nResourceGroupName       Name  Location VmSize OsType NIC ProvisioningState Zone\r\n-----------------       ----  -------- ------ ------ --- ----------------- ----\r\nSHUDA1215         shuda1215a japaneast                           Succeeded\r\nSHUDA1215         shuda1215b japaneast                           Succeeded\r\nSHUDA1221         shuda1221a japaneast                           Succeeded\r\nSHUDA1221         shuda1221b japaneast                           Succeeded<\/pre>\n<p>\u3053\u308c\u306e\u4f55\u304c\u3046\u308c\u3057\u3044\u304b\u3068\u3044\u3046\u3068\u3001PSJob \u3092\u4f7f\u3044\u3053\u306a\u3059\u3053\u3068\u3067\u6642\u9593\u306e\u304b\u304b\u308b\u30b3\u30de\u30f3\u30c9\u3092\u30d1\u30e9\u30ec\u30eb\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u306e\u3067\u3001\u4f5c\u6210\u306b\u6642\u9593\u306e\u304b\u304b\u308b\u30ea\u30bd\u30fc\u30b9 (Gateway \u3068\u304b) \u3092\u8907\u6570\u4f5c\u308b\u3068\u304d\u3084\u3001\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u3092\u307e\u305f\u3044\u3067\u4e26\u5217\u51e6\u7406\u3092\u3057\u305f\u3044\u3068\u304d\u306b\u5927\u5909\u306f\u304b\u3069\u308a\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u3053\u3093\u306a\u611f\u3058\u3067\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u3092\u5207\u308a\u66ff\u3048\u3066\u3001\u5168\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u306e VM \u4e00\u89a7\u3092\u53d6\u5f97\u3057\u305f\u308a\u3068\u304b\u3002<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">Get-AzureRmSubscription | foreach{\r\n\r\n    # \u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u3092\u5207\u308a\u66ff\u3048\u3066\r\n    Select-AzureRmSubscription -SubscriptionId $_.SubscriptionID\r\n\r\n    # \u30b8\u30e7\u30d6\u3092\u5b9f\u884c\r\n    Start-Job{\r\n        param($ctx)\r\n\r\n        Get-AzureRmVM -AzureRmContext $ctx\r\n    } -ArgumentList (Get-AzureRmContext)\r\n}\r\n\r\n# \u5404\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u306b\u5bfe\u3057\u3066\u30b8\u30e7\u30d6\u304c\u5b9f\u884c\u3055\u308c\u308b\r\nGet-Job\r\n\r\nId     Name            PSJobTypeName   State         HasMoreData     Location             Command\r\n--     ----            -------------   -----         -----------     --------             -------\r\n1      Job1            BackgroundJob   Completed     True            localhost            ...\r\n3      Job3            BackgroundJob   Completed     True            localhost            ...\r\n5      Job5            BackgroundJob   Completed     True            localhost            ...\r\n7      Job7            BackgroundJob   Completed     True            localhost            ...\r\n9      Job9            BackgroundJob   Completed     True            localhost            ..\r\n<\/pre>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u53bb\u5e74\u307e\u3067\u306f\u300c\u53e3\u3092\u52d5\u304b\u3059\u524d\u306b\u3001\u624b\u3092\u52d5\u304b\u305b\u300d\u304c\u53e3\u7656\u3067\u3057\u305f\u304c\u3001\u4eca\u5e74\u306f\u624b\u3092\u52d5\u304b\u3059\u624b\u9593\u3055\u3048\u3082\u7701\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><iframe loading=\"lazy\" width=\"860\" height=\"484\" src=\"https:\/\/www.youtube.com\/embed\/E53zncxwnLo?start=469&#038;feature=oembed\" frameborder=\"0\" gesture=\"media\" allow=\"encrypted-media\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5148\u307b\u3069\u306e\u30ed\u30b0\u30a4\u30f3\u81ea\u52d5\u5316\u306b\u7d9a\u3044\u3066\u3001Azure PowerShell 4.4.0 \u4ee5&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/www.syuheiuda.com\/?p=4138\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_locale":"","_original_post":""},"categories":[39,31],"tags":[],"views":5162,"_links":{"self":[{"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/posts\/4138"}],"collection":[{"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4138"}],"version-history":[{"count":15,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/posts\/4138\/revisions"}],"predecessor-version":[{"id":4156,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/posts\/4138\/revisions\/4156"}],"wp:attachment":[{"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}