Download - Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~
![Page 1: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/1.jpg)
Microsoft Tech Summit 2017
![Page 2: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/2.jpg)
![Page 3: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/3.jpg)
PS C:\> Get-Profile -Name “Shuhei Uda” | Format-List
名前 : 宇田周平職種 : サポートエンジニア
2015/12 – 2017/11
Azure (IaaS / Networking)
2013/06 – 2015/11
Windows (Hyper-V / RDS / Performance)
![Page 4: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/4.jpg)
![Page 5: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/5.jpg)
![Page 6: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/6.jpg)
![Page 7: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/7.jpg)
「何もしてないのに壊れました」
「Windows Update したら調子が悪い」
![Page 8: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/8.jpg)
データのバックアップ・リストア
アプリケーションの再インストール
![Page 9: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/9.jpg)
![Page 10: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/10.jpg)
![Page 11: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/11.jpg)
# 実行ポリシーを設定 (要管理者権限)
Set-ExecutionPolicy RemoteSigned -Force
# Provider を検索
Find-PackageProvider -Force
# Provider を登録
Get-PackageProvider -Name Chocolatey -ForceBootstrap
# パッケージ検索
Find-Package
# インストール
Install-Package -Name Firefox -Force
Install-Package -Name teraterm -Force
![Page 12: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/12.jpg)
![Page 13: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/13.jpg)
0
500
1000
1500
2000
2500
3000
![Page 14: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/14.jpg)
![Page 15: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/15.jpg)
PS C:\> <Do> - <Something>
(取得) Get - AzureVM
(作成) New - AzureStorageAccount
(変更) Set - AzureRmVirtualNetwork
(削除) Remove - AzureRmPublicIpAddress
# Get-AzureVM: クラシックデプロイモデル向け# Get-AzureRmVM: リソースマネージャーモデル向け
![Page 16: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/16.jpg)
# まずは Get-AzureRmXXXXから始めましょう!
PS C:\> Get-AzureRmVm
ResourceGroupName Name Location VmSize OsType
----------------- ---- -------- ------ ------
ArmResourceGroup LinuxVM EastAsia Basic_A0 Linux
ArmResourceGroup WindowsVM EastAsia Standard_DS2_v2 Windows
# Get コマンドだけでも様々な情報が取得できますし、# 情報取得のみであれば、環境を壊すこともありません
![Page 17: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/17.jpg)
$VM = Get-AzureRmVM
$StorageAccount = Get-AzureRmStorageAccount
$VirtualNetwork = Get-AzureRmVirtualNetwork
$ResourceGroup = Get-AzureRmResourceGroup
$PublicIpAddress = Get-AzureRmPublicIpAddress
$NetworkInterface = Get-AzureRmNetworkInterface
$NetworkSecurityGroup = Get-AzureRmNetworkSecurityGroup
$LoadBalancer = Get-AzureRmLoadBalancer
# Get-Command Get-AzureRm* でコマンドの一覧が取得可能
![Page 18: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/18.jpg)
参考: https://github.com/ShuheiUda/Get-SubscriptionDetails
![Page 19: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/19.jpg)
![Page 20: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/20.jpg)
management.core.windows.net
management.azure.com
Resource
Provider
REST API
Endpoint
PowerShell
Console
User
Input
2. HTTP Request
(Get / Put)
1. コマンド入力
(ex. New-AzureRmVM)
4. HTTP Response
(200 / 404 / 503)
3. 内部処理
5. 結果を出力
![Page 21: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/21.jpg)
management.core.windows.net
management.azure.com
Resource
Provider
REST API
Endpoint
PowerShell
Console
User
Input
2. HTTP Request2. HTTP Request
(Get / Put)
1. コマンド入力
(ex. New-AzureRmVM)
4. HTTP Response
(200 / 404 / 503)
3. 内部処理
5. 結果を出力
• xxxx は、コマンドレット、関数、スクリプト ファイル、または操作可能なプログラムの名前として認識されません。
• パラメーター名 ‘xxxx' に一致するパラメーターが見つかりません。• パラメーター 'VM' をバインドできません。“xxxx" の値を "System.String" 型から
"Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine" 型に変換できません。
etc…
![Page 22: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/22.jpg)
management.core.windows.net
management.azure.com
Resource
Provider
REST API
Endpoint
PowerShell
Console
User
Input
2. HTTP Request2. HTTP Request
(Get / Put)
1. コマンド入力
(ex. New-AzureRmVM)
4. HTTP Response
(200 / 404 / 503)
3. 内部処理
5. 結果を出力
• この要求の送信中にエラーが発生しました。
![Page 23: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/23.jpg)
management.core.windows.net
management.azure.com
Resource
Provider
REST API
Endpoint
PowerShell
Console
User
Input
2. HTTP Request2. HTTP Request
(Get / Put)
1. コマンド入力
(ex. New-AzureRmVM)
4. HTTP Response
(200 / 404 / 503)
3. 内部処理
5. 結果を出力
• InternalError: The server encountered an internal error.Please retry the request.
![Page 24: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/24.jpg)
![Page 25: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/25.jpg)
![Page 26: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/26.jpg)
![Page 27: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/27.jpg)
![Page 28: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/28.jpg)
![Page 29: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/29.jpg)
PS C:\> Get-AzureRmVMBootDiagnosticsData
-Name <VMName> -ResourceGroupName <RGName>
-Windows -LocalPath <C:\logs>
1. 時刻がずれていないかを確認(OS がハングアップしていないか)
2. ネットワーク接続状況を確認
![Page 30: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/30.jpg)
PS C:\> Get-AzureRmEffectiveNetworkSecurityGroup
-NetworkInterfaceName <NICName>
-ResourceGroupName <RGName>
![Page 31: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/31.jpg)
PS C:\> Test-AzureRmTraffic.ps1 -VMName VMName
-SourceIPv4Address <IP> -SourcePort <Port>
-DestinationIPv4Address <IP> -DestinationPort <Port>
-Protocol <TCP/UDP> -Direction <Inbound/Outbound>
# ダウンロード先
# https://github.com/ShuheiUda/Test-AzureRmTraffic
![Page 32: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/32.jpg)
![Page 33: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/33.jpg)
PS C:\> Test-AzureRmTraffic.ps1 -VMName Name -SourceIPv4Address 203.0.113.4
-SourcePort 65000 -DestinationIPv4Address 10.0.0.4 -DestinationPort 443
-Protocol TCP -Direction Inbound
Access : Deny
Priority : 4096
Name : securityRules/DenyAll
Protocol : All
SourceAddressPrefix : 0.0.0.0/0
SourcePortRange : 0-65535
DestinationAddressPrefix : 0.0.0.0/0
DestinationPortRange : 0-65535
Direction : Inbound
![Page 34: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/34.jpg)
PS C:\> Test-AzureRmTraffic.ps1 -VMName Name -SourceIPv4Address 203.0.113.4
-SourcePort 65000 -DestinationIPv4Address 10.0.0.4 -DestinationPort 3389
-Protocol TCP -Direction Inbound
Access : Allow
Priority : 1000
Name : securityRules/default-allow-rdp
Protocol : Tcp
SourceAddressPrefix : 0.0.0.0/0
SourcePortRange : 0-65535
DestinationAddressPrefix : 0.0.0.0/0
DestinationPortRange : 3389-3389
Direction : Inbound
![Page 35: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/35.jpg)
# 本日の資料はこちら http://aka.ms/DEP006
![Page 36: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/36.jpg)
![Page 37: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/37.jpg)
![Page 38: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/38.jpg)
■ https://www.powershellgallery.com/
■
https://channel9.msdn.com/Events/de-code/2016/INF-009
■
https://qiita.com/jca02266/items/a0c71ae90d055ab3893c
■ http://winscript.jp/powershell/
![Page 39: Azure サポート エンジニア直伝 ~ PowerShell 実践活用術 ~](https://reader033.vdocuments.net/reader033/viewer/2022052117/5a64797f7f8b9a6a568b466f/html5/thumbnails/39.jpg)
■
https://docs.microsoft.com/ja-jp/powershell/azure/overview
■ https://github.com/Azure/azure-powershell
■
https://www.syuheiuda.com/?p=3489
■ https://blogs.technet.microsoft.com/jpaztech/