{"id":2863,"date":"2023-02-06T10:00:00","date_gmt":"2023-02-06T01:00:00","guid":{"rendered":"https:\/\/www.itc109.com\/knowledge\/?p=2863"},"modified":"2023-09-03T03:11:20","modified_gmt":"2023-09-02T18:11:20","slug":"auzre-powershell%e3%81%a7%e3%83%8d%e3%83%83%e3%83%88%e3%83%af%e3%83%bc%e3%82%af%e3%82%bb%e3%82%ad%e3%83%a5%e3%83%aa%e3%83%86%e3%82%a3%e3%82%b0%e3%83%ab%e3%83%bc%e3%83%97%e3%81%ae%e4%bd%9c%e6%88%90","status":"publish","type":"post","link":"https:\/\/www.itc109.com\/knowledge\/powershell\/auzre-powershell%e3%81%a7%e3%83%8d%e3%83%83%e3%83%88%e3%83%af%e3%83%bc%e3%82%af%e3%82%bb%e3%82%ad%e3%83%a5%e3%83%aa%e3%83%86%e3%82%a3%e3%82%b0%e3%83%ab%e3%83%bc%e3%83%97%e3%81%ae%e4%bd%9c%e6%88%90","title":{"rendered":"Auzre &#8211; PowerShell\u3067\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u6982\u8981<\/h2>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p>AWS\u3092\u30e1\u30a4\u30f3\u3067\u5229\u7528\u3057\u3066\u3044\u308b\u30a8\u30f3\u30b8\u30cb\u30a2\u304cAzure\u74b0\u5883\u306e\u69cb\u7bc9\u3092PowerShell\u3067\u9032\u3081\u308b\u9023\u8f09\u3002<br>\n\u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210\u304b\u3089\u4eee\u60f3\u30de\u30b7\u30f3\u3092\u8d77\u52d5\u3059\u308b\u307e\u3067\u3092\u9023\u8f09\u3057\u3066\u3044\u304f\u4e88\u5b9a\u3067\u3059\u3002<\/p>\n<p>\u7b2c3\u56de\u306f\u3001\u4f5c\u6210\u3057\u305f\u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u306b\u3001AWS\u3067\u8a00\u3046\u3068\u3053\u308d\u306eVPC\u306b\u985e\u4f3c\u3059\u308b\u30b5\u30fc\u30d3\u30b9\u300c\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u300d\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/www.itc109.com\/knowledge\/?p=2800\">\u7b2c01\u56de PowerShell\u3067Azure\u306b\u63a5\u7d9a<\/a><\/li>\n<li><a href=\"https:\/\/www.itc109.com\/knowledge\/?p=2836\">\u7b2c02\u56de PowerShell\u3067\u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210<\/a><\/li>\n<li>\u7b2c03\u56de PowerShell\u3067\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210\u3000\u2190\u2605\u3053\u3053<\/li>\n<li>\u7b2c04\u56de PowerShell\u3067\u53d7\u4fe1\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u898f\u5247\u306e\u8ffd\u52a0<\/li>\n<li>\u7b2c05\u56de PowerShell\u3067\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u4f5c\u6210<\/li>\n<li>\u7b2c06\u56de PowerShell\u3067\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306e\u4f5c\u6210<\/li>\n<li>\u7b2c07\u56de PowerShell\u3067\u30d1\u30d6\u30ea\u30c3\u30afIP\u30a2\u30c9\u30ec\u30b9\u306e\u4f5c\u6210<\/li>\n<li>\u7b2c08\u56de PowerShell\u3067\u4eee\u60f3\u30de\u30b7\u30f3\u306e\u4f5c\u6210<\/li>\n<li>\u7b2c09\u56de PowerShell\u3067\u30ea\u30bd\u30fc\u30b9\u306e\u30ed\u30c3\u30af<\/li>\n<\/ul>\n<p>\u756a\u5916\u7de8<\/p>\n<ul>\n<li>\u7b2c10\u56de PowerShell\u3067\u30b9\u30c8\u30ec\u30fc\u30b8\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u4f5c\u6210<\/li>\n<li>\u7b2c11\u56de PowerShell\u3067\u4eee\u60f3\u30de\u30b7\u30f3\u7528VHD\u30a4\u30e1\u30fc\u30b8\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9<\/li>\n<li>\u7b2c12\u56de PowerShell\u3067\u4eee\u60f3\u30de\u30b7\u30f3\u3092VHD\u30a4\u30e1\u30fc\u30b8\u304b\u3089\u4f5c\u6210<\/li>\n<li>\u7b2c13\u56de PowerShell\u3067\u30c7\u30a3\u30b9\u30af\u306e\u62e1\u5f35<\/li>\n<\/ul>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u624b\u9806<\/h2>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p>\u524d\u63d0\uff1a\u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u308b\u4e8b\u3002<\/p>\n<\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code># \u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u540d\u3092\u8a2d\u5b9a\n$private:resourceGroupName = &quot;rg001&quot;\n\n# \u30ed\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\n$private:location = &quot;japaneast&quot;\n\n# \u30bf\u30b0\u3092\u8a2d\u5b9a\n$tags = @{&quot;\u74b0\u5883\u540d&quot;=&quot;ITC109&quot;}<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>##################################################\nWrite-Host &quot;\u25a0\u25a0 \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210\u51e6\u7406 \u25a0\u25a0&quot;\n##################################################\n# \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u540d\u3092\u8a2d\u5b9a\n$script:nwSgPublicName = $private:resourceGroupName + &quot;nwsg-public&quot;  \n$script:nwSgPrivateName = $private:resourceGroupName + &quot;nwsg-private&quot; \n\n# \u4f5c\u6210\u4e88\u5b9a\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u306e\u6709\u7121\u3092\u78ba\u8a8d\n$script:nwSgPublic = Get-AzNetworkSecurityGroup -ResourceGroupName $private:resourceGroupName -Name $script:nwSgPublicName -ErrorAction Ignore\n\nif (-not $script:nwSgPublic) {\n    try{\n        # \u30d1\u30d6\u30ea\u30c3\u30af\u7528\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u4f5c\u6210\n        Write-Host (&quot;${private:resourceGroupName} \u306e\u300c\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u300d\u306b ${script:nwSgPublicName} \u3092\u4f5c\u6210\u4e2d...&quot;)\n        $script:nsg = New-AzNetworkSecurityGroup -Location $private:location -ResourceGroupName $private:resourceGroupName -Name $script:nwSgPublicName -Tag $tags -ErrorAction Stop\n        Write-Host (&quot;${private:resourceGroupName} \u306e\u300c\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u300d\u306b ${script:nwSgPublicName} \u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002&quot;)\n        Write-Host &quot;&quot;\n\n    }catch{\n        Write-Host &quot;${private:resourceGroupName} \u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u4f5c\u6210\u30a8\u30e9\u30fc&quot; -ForegroundColor Red\n        Write-Error -Message $_.Exception\n        Write-Host &quot;&quot;\n\n    }\n\n} else {\n    Write-Host (&quot;${private:resourceGroupName} \u306e\u300c\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u300d\u306b\u306f\u3001\u65e2\u306b ${script:nwSgPublicName} \u304c\u5b58\u5728\u3059\u308b\u305f\u3081\u4f5c\u6210\u3092\u30b9\u30ad\u30c3\u30d7\u3057\u307e\u3057\u305f\u3002&quot;) -ForegroundColor Yellow\n    Write-Host &quot;&quot;\n\n}\n\n# \u4f5c\u6210\u4e88\u5b9a\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u306e\u6709\u7121\u3092\u78ba\u8a8d\n$script:nwSgPrivate = Get-AzNetworkSecurityGroup -ResourceGroupName $private:resourceGroupName -Name $script:nwSgPrivateName -ErrorAction Ignore\n\nif (-not $script:nwSgPrivate) {\n    try{\n        # \u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u7528\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u4f5c\u6210\n        Write-Host (&quot;${private:resourceGroupName} \u306e\u300c\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u300d\u306b ${script:nwSgPrivateName} \u3092\u4f5c\u6210\u4e2d...&quot;)\n        $script:nsg = New-AzNetworkSecurityGroup -Location $private:location -ResourceGroupName $private:resourceGroupName -Name $script:nwSgPrivateName -Tag $tags -ErrorAction Stop\n        Write-Host (&quot;${private:resourceGroupName} \u306e\u300c\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u300d\u306b ${script:nwSgPrivateName} \u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002&quot;)\n        Write-Host &quot;&quot;\n\n    }catch{\n        Write-Host &quot;${private:resourceGroupName} \u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u4f5c\u6210\u30a8\u30e9\u30fc&quot; -ForegroundColor Red\n        Write-Error -Message $_.Exception\n        Write-Host &quot;&quot;\n\n    }\n\n} else {\n    Write-Host (&quot;${private:resourceGroupName} \u306e\u300c\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u300d\u306b\u306f\u3001\u65e2\u306b ${script:nwSgPrivateName} \u304c\u5b58\u5728\u3059\u308b\u305f\u3081\u4f5c\u6210\u3092\u30b9\u30ad\u30c3\u30d7\u3057\u307e\u3057\u305f\u3002&quot;) -ForegroundColor Yellow\n    Write-Host &quot;&quot;\n\n}\n\n##################################################<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u306e\u540d\u524d\u3092\u8a2d\u5b9a\u3002<\/p>\n<\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>$script:nwSgName = &quot;nwsg&quot; + $private:resourceGroupName<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p><code>Get-AzNetworkSecurityGroup<\/code>\u3067\u65e2\u306b\u540c\u540d\u306e\u30ea\u30bd\u30fc\u30b9\u304c\u5b58\u5728\u3057\u306a\u3044\u304b\u78ba\u8a8d\u3002<\/p>\n<\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>$script:nwSg = Get-AzNetworkSecurityGroup -ResourceGroupName $private:resourceGroupName -Name $script:nwSgName -ErrorAction Ignore\n\nif (-not $script:nwSg) {\n  \u203b\u30ea\u30bd\u30fc\u30b9\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f\u3001\u3053\u3053\u306b\u4f5c\u6210\u3059\u308b\u51e6\u7406\u3092\u8a18\u8ff0\u3002\n} else {\n  \u203b\u30ea\u30bd\u30fc\u30b9\u304c\u5b58\u5728\u3059\u308b\u5834\u5408\u306f\u3001\u3053\u3053\u306b\u4f5c\u6210\u3057\u306a\u3044\u51e6\u7406\u3092\u8a18\u8ff0\u3002\n}<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p><code>New-AzNetworkSecurityGroup<\/code>\u3067\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\u3002<\/p>\n<\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>New-AzNetworkSecurityGroup -Location $private:location -ResourceGroupName $private:resourceGroupName -Name $script:nwSgName -Tag $tags<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p><code>try \uff5e catch<\/code>\u3067\u4f8b\u5916\u304c\u767a\u751f\u3057\u305f\u3068\u304d\u306b\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3002<\/p>\n<\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>try {\n    \u203b\u30ea\u30bd\u30fc\u30b9\u306e\u4f5c\u6210\u306e\u4f5c\u6210\u3002\n} catch {\n    \u203b\u30ea\u30bd\u30fc\u30b9\u306e\u4f5c\u6210\u306e\u4f5c\u6210\u306b\u5931\u6557\u3002\n    Write-Error -Message $_.Exception\n}<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u30ea\u30bd\u30fc\u30b9 \u30d3\u30b8\u30e5\u30a2\u30e9\u30a4\u30b6\u30fc<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7-1024x576.png\" alt=\"\" class=\"wp-image-3085\" srcset=\"https:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7-1024x576.png 1024w, https:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7-300x169.png 300w, https:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7-768x432.png 768w, https:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7-1536x864.png 1536w, https:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7-2048x1151.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 \u624b\u9806 \u30ea\u30bd\u30fc\u30b9 \u30d3\u30b8\u30e5\u30a2\u30e9\u30a4\u30b6\u30fc<\/p>\n","protected":false},"author":3,"featured_media":2808,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[125,81],"tags":[75],"class_list":["post-2863","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-powershell","tag-powershell"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.itc109.com\/knowledge\/wp-content\/uploads\/sites\/2\/Azure.png","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pacZwp-Kb","_links":{"self":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/2863","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/comments?post=2863"}],"version-history":[{"count":27,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/2863\/revisions"}],"predecessor-version":[{"id":3173,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/2863\/revisions\/3173"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/media\/2808"}],"wp:attachment":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/media?parent=2863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/categories?post=2863"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/tags?post=2863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}