{"id":2836,"date":"2023-01-30T10:00:00","date_gmt":"2023-01-30T01:00:00","guid":{"rendered":"https:\/\/www.itc109.com\/knowledge\/?p=2836"},"modified":"2023-09-03T03:12:15","modified_gmt":"2023-09-02T18:12:15","slug":"azure-powershell%e3%81%a7%e3%83%aa%e3%82%bd%e3%83%bc%e3%82%b9%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\/azure-powershell%e3%81%a7%e3%83%aa%e3%82%bd%e3%83%bc%e3%82%b9%e3%82%b0%e3%83%ab%e3%83%bc%e3%83%97%e3%81%ae%e4%bd%9c%e6%88%90","title":{"rendered":"Azure &#8211; PowerShell\u3067\u30ea\u30bd\u30fc\u30b9\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>\u7b2c2\u56de\u306f\u3001\u3053\u308c\u304b\u3089\u4f5c\u6210\u3059\u308b\u30ea\u30bd\u30fc\u30b9\u3092\u7ba1\u7406\u3059\u308b\u300c\u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\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>\u7b2c02\u56de PowerShell\u3067\u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210\u3000\u2190\u2605\u3053\u3053<\/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<\/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\u4e8b\u524d\u306bAzure\u306b\u63a5\u7d9a\u3057\u3066\u3044\u308b\u4e8b\u3002<\/p>\n<\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><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 \u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210 \u25a0\u25a0&quot;\n##################################################\n# \u4f5c\u6210\u4e88\u5b9a\u306e\u30ea\u30bd\u30fc\u30b9\u6709\u7121\u3092\u78ba\u8a8d\n$private:resourceGroup = Get-AzResourceGroup -Location $private:location -Name $private:resourceGroupName -ErrorAction Ignore\n\nif (-not $private:resourceGroup) {\n  try {\n    #\u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210\n    Write-Host (&quot;\u300c\u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u300d\u306b ${private:resourceGroupName} \u3092\u4f5c\u6210\u4e2d...&quot;)\n    $null = New-AzResourceGroup -Location $private:location -Name $private:resourceGroupName -Tag $tags -ErrorAction Stop\n    Write-Host (&quot;\u300c\u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u300d\u306b ${private:resourceGroupName} \u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002&quot;)\n    Write-Host &quot;&quot;\n\n  } catch {\n    Write-Host &quot;\u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u4f5c\u6210\u30a8\u30e9\u30fc&quot; -ForegroundColor Red\n    Write-Error -Message $_.Exception\n\n  }\n} else {\n  Write-Host (&quot;\u300c\u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u300d\u306b\u306f\u3001\u65e2\u306b ${private:resourceGroupName} \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><code>Get-AzResourceGroup<\/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>Get-AzResourceGroup -Location $private:location -Name $private:resourceGroupName -ErrorAction Ignore<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p><code>New-AzResourceGroup<\/code>\u3067\u30ea\u30bd\u30fc\u30b9\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-plain\"><code>New-AzResourceGroup -Location $private:location -Name $private:resourceGroupName -Tag $tags -ErrorAction Stop<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p>\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3057\u3066\u4ee5\u4e0b\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002(\u203b\u306f\u5fc5\u9808\u306e\u30aa\u30d7\u30b7\u30e7\u30f3)<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p><code>-Location<\/code>\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u4f5c\u6210\u3059\u308b\u30ea\u30fc\u30b8\u30e7\u30f3\u3092\u8a2d\u5b9a\u3002\u203b<\/p>\n<\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>-Location $private:location<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p><code>-Name<\/code>\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u4f5c\u6210\u3059\u308b\u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u540d\u3092\u8a2d\u5b9a\u3002\u203b<\/p>\n<\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>-Name $private:resourceGroupName<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p>\u7ba1\u7406\u7528\u306e\u30bf\u30b0\u3092\u8a2d\u5b9a\u3059\u308b\u5834\u5408\u306f\u3001<code>-Tag<\/code>\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u6307\u5b9a\u3002<br>\n\u30bf\u30b0\u5909\u6570\u306f\u914d\u5217\u3067\u300c\u30ad\u30fc\u300d\u3068\u300c\u5024\u300d\u3067\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># \u30bf\u30b0\u3092\u8a2d\u5b9a\n$tags = @{&quot;\u74b0\u5883\u540d&quot;=&quot;ITC109&quot;}\n\n-Tag $tags<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p><code>-ErrorAction<\/code>\u30aa\u30d7\u30b7\u30e7\u30f3\u306b <code>stop<\/code> \u3092\u6307\u5b9a\u3059\u308b\u3068\u3001\u30a8\u30e9\u30fc\u6642\u306b\u505c\u6b62\u3002<\/p>\n<\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>-ErrorAction Stop<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p><code>-ErrorAction<\/code>\u30aa\u30d7\u30b7\u30e7\u30f3\u306b <code>Ignore<\/code> \u3092\u6307\u5b9a\u3059\u308b\u3068\u3001\u30a8\u30e9\u30fc\u7121\u8996\u3057\u3066\u7d9a\u884c\u3002<\/p>\n<\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>-ErrorAction Ignore<\/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-plain\"><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}<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p>\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3059\u308b\u5834\u5408\u306f <code>$_.Exception<\/code> \u3092\u4f7f\u7528\u3002<\/p>\n<\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>Write-Error -Message $_.Exception<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u88dc\u8db3<\/h2>\n\n\n\n<div class=\"wp-block-jetpack-markdown\"><p>\u30b3\u30f3\u30bd\u30fc\u30eb\u3067\u8868\u793a\u3055\u308c\u308b\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u30ab\u30e9\u30fc\u3067\u8868\u793a\u3057\u305f\u3044\u5834\u5408\u306f <code>ForegroundColor<\/code> \u3067\u8272\u3092\u6307\u5b9a\u3059\u308b\u3002<\/p>\n<\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code># \u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u30ec\u30c3\u30c9\u3067\u8868\u793a\u3059\u308b\u5834\u5408\u306f\u300cRed\u300d\u3092\u6307\u5b9a\n-ForegroundColor Red\n\n# \u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u30a4\u30a8\u30ed\u30fc\u3067\u8868\u793a\u3059\u308b\u5834\u5408\u306f\u300cYellow\u300d\u3092\u6307\u5b9a\n-ForegroundColor Yellow<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981 \u624b\u9806 \u88dc\u8db3<\/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-2836","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-JK","_links":{"self":[{"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/2836","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=2836"}],"version-history":[{"count":28,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/2836\/revisions"}],"predecessor-version":[{"id":3174,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/posts\/2836\/revisions\/3174"}],"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=2836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/categories?post=2836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itc109.com\/knowledge\/wp-json\/wp\/v2\/tags?post=2836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}