Get-Module -ListAvailable
- 설치된 모듈 확인
PS C:\Users\azureking> Get-Module -ListAvailable 디렉터리: C:\Program Files\WindowsPowerShell\Modules ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Script 1.0.1 Microsoft.PowerShell.Operation.V... {Get-OperationValidation, Invoke-OperationValidation} Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packa... Script 3.4.0 Pester {Describe, Context, It, Should...} Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...} Script 1.2 PSReadline {Get-PSReadlineKeyHandler, Set-PSReadlineKeyHandler, Remov... 디렉터리: C:\Windows\system32\WindowsPowerShell\v1.0\Modules ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Manifest 1.0.0.0 AppBackgroundTask {Disable-AppBackgroundTaskDiagnosticLog, Enable-AppBackgro... Manifest 2.0.0.0 AppLocker {Get-AppLockerFileInformation, Get-AppLockerPolicy, New-Ap... Manifest 1.0.0.0 AppvClient {Add-AppvClientConnectionGroup, Add-AppvClientPackage, Add... Manifest 2.0.0.0 Appx {Add-AppxPackage, Get-AppxPackage, Get-AppxPackageManifest... <생략> 디렉터리: C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Manifest 0.0.4 AzureRM.AnalysisServices {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnal... Manifest 3.4.0 AzureRM.ApiManagement {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementS... Manifest 2.6.0 AzureRM.Automation {Get-AzureRMAutomationHybridWorkerGroup, Get-AzureRmAutoma... Manifest 2.6.0 AzureRM.Backup {Backup-AzureRmBackupItem, Enable-AzureRmBackupContainerRe... <생략> 디렉터리: C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Manifest 3.5.0 Azure {Get-AzureAutomationCertificate, Get-AzureAutomationConnec... 디렉터리: C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\Storage ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Manifest 2.6.0 Azure.Storage {Get-AzureStorageTable, New-AzureStorageTableSASToken, New...
파일 찾기
PS C:\Users\azureking> dir C:\windows\System32 -FIlter *sam* -Recurse 디렉터리: C:\windows\System32 Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 2016-07-16 오후 8:42 253952 iassam.dll -a---- 2016-07-16 오후 8:42 129536 MSAMRNBDecoder.dll -a---- 2016-07-16 오후 8:42 209408 MSAMRNBEncoder.dll -a---- 2016-07-16 오후 8:42 28672 MSAMRNBSink.dll -a---- 2016-07-16 오후 8:42 90624 MSAMRNBSource.dll -a---- 2016-12-21 오후 5:08 245600 offlinesam.dll -a---- 2016-07-16 오후 8:42 246360 RESAMPLEDMO.DLL -a---- 2016-07-16 오후 8:42 79360 samcli.dll -a---- 2016-08-06 오후 12:29 123904 samlib.dll -a---- 2016-12-21 오후 3:59 883712 samsrv.dll <생략>
Login-AzureRmAccount
- Azure 접속
(처음)
PS C:\Users\azureking> Login-AzureRmAccount 경고: Microsoft Azure PowerShell collects data about how users use PowerShell cmdlets and some problems they encounter. Microsoft uses this information to improve our PowerShell cmdlets. Participation is voluntary and when you choose to participate your device automatically sends information to Microsoft about how you use Azure PowerShell. If you choose to participate, you can stop at any time by using Azure PowerShell as follows: 1. Use the Disable-AzureDataCollection cmdlet to turn the feature Off. The cmdlet can be found in the AzureResourceManager module To disable data collection: PS > Disable-AzureDataCollection If you choose to not participate, you can enable at any time by using Azure PowerShell as follows: 1. Use the Enable-AzureDataCollection cmdlet to turn the feature On. The cmdlet can be found in the AzureResourceManager module To enable data collection: PS > Enable-AzureDataCollection Select Y to enable data collection [Y/N]: 경고: You choose to participate in Microsoft Azure PowerShell data collection. 경고: The setting profile has been saved to the following path 'C:\Users\azureking\AppData\Roaming\Windows Azure
(이후)
PS C:\Users\azureking> Login-AzureRmAccount
Environment : AzureCloud
Account : 이 이메일 주소가 스팸봇으로부터 보호됩니다. 확인하려면 자바스크립트 활성화가 필요합니다.
TenantId : abcd1234-aabf-4d78-999a-xyzxyzxyzxyz
SubscriptionId : abcd1234-0687-484a-810c-xyzxyzxyzxyz
SubscriptionName : Azure Pass
CurrentStorageAccount :
Get-AzureRmSubscription
- 계약 확인
PS C:\Users\azureking> Get-AzureRmSubscription SubscriptionName : Azure Pass SubscriptionId : abcd1234-0687-484a-810c-xyzxyzxyzxyz TenantId : abcd1234-aabf-4d78-999a-xyzxyzxyzxyz State : Enabled
Get-AzureRmVM
The Get-AzureRmVM cmdlet gets the model view and instance view of an Azure virtual machine. The model view is the user specified properties of the virtual machine. The instance view is the instance level status of the virtual machine. Specify the Status parameter to get only the instance view of a virtual machine.-
- VM 확인
PS C:\Users\azureking> Get-AzureRmVM 경고: Breaking change notice: In upcoming release, top level properties, DataDiskNames and NetworkInterfaceIDs, will be removed from VM object because they are also in StorageProfile and NetworkProfile, respectively. ResourceGroupName Name Location VmSize OsType NIC ProvisioningState ----------------- ---- -------- ------ ------ --- ----------------- RGTEST king-vm-centos-01 eastasia Standard_DS1_v2 Linux king-vm-centos-01946 Succeeded
Get-AzureRmVM -ResourceGroupName [GROUP_NAME]
- ResourceGroup 내 VM 확인
PS C:\Users\azureking> Get-AzureRmVM -ResourceGroupName rgtest 경고: Breaking change notice: In upcoming release, top level properties, DataDiskNames and NetworkInterfaceIDs, will be removed from VM object because they are also in StorageProfile and NetworkProfile, respectively. ResourceGroupName Name Location VmSize OsType NIC ProvisioningState ----------------- ---- -------- ------ ------ --- ----------------- rgtest king-vm-centos-01 eastasia Standard_DS1_v2 Linux king-vm-centos-01946 Succeeded
Get-AzureRmVM -ResourceGroupName [GROUP_NAME] -Name [VM_NAME]
- 개별 VM 확인
PS C:\Users\azureking> Get-AzureRmVM -ResourceGroupName rgtest -Name king-vm-centos-01 경고: Breaking change notice: In upcoming release, top level properties, DataDiskNames and NetworkInterfaceIDs, will be removed from VM object because they are also in StorageProfile and NetworkProfile, respectively. ResourceGroupName : rgtest Id : /subscriptions/abcd1234-0687-484a-810c-xyzxyzxyzxyz/resourceGroups/rgtest/providers/Microsoft.Com pute/virtualMachines/king-vm-centos-01 VmId : abcd1234-b172-40bf-bff8-xyzxyzxyzxyz Name : king-vm-centos-01 Type : Microsoft.Compute/virtualMachines Location : eastasia Tags : {} DiagnosticsProfile : {BootDiagnostics} HardwareProfile : {VmSize} NetworkProfile : {NetworkInterfaces} OSProfile : {ComputerName, AdminUsername, LinuxConfiguration, Secrets} ProvisioningState : Succeeded StorageProfile : {ImageReference, OsDisk, DataDisks} NetworkInterfaceIDs : {/subscriptions/abcd1234-0687-484a-810c-xyzxyzxyzxyz/resourceGroups/RGTest/providers/Microsoft.Ne twork/networkInterfaces/king-vm-centos-01946}
Get-AzureRmVM -ResourceGroupName rgtest -Name [VM_NAME] | Stop-AzureRmVM
The Stop-AzureRmVM cmdlet stops an Azure virtual machine.
- VM Stop
- 정상적으로 끝나면 Portal에서 "Stopped (deallocated)"
PS C:\Users\azureking> Get-AzureRmVM -ResourceGroupName rgtest -Name king-vm-centos-01 | Stop-AzureRmVM 경고: Breaking change notice: In upcoming release, top level properties, DataDiskNames and NetworkInterfaceIDs, will be removed from VM object because they are also in StorageProfile and NetworkProfile, respectively. Virtual machine stopping operation This cmdlet will stop the specified virtual machine. Do you want to continue? [Y] 예(Y) [N] 아니요(N) [S] 일시 중단(S) [?] 도움말 (기본값은 "Y"): y OperationId : Status : Succeeded StartTime : 2017-04-03 오후 2:56:01 EndTime : 2017-04-03 오후 2:59:07 Error :
PowerShell을 통해 자동 로그인하기
$user="이 이메일 주소가 스팸봇으로부터 보호됩니다. 확인하려면 자바스크립트 활성화가 필요합니다."
$pwd="myPassword" | ConvertTo-SecureString -AsPlainText -Force
$cred=New-Object -TypeName System.Management.Automation.PSCredential -Args $user, $pwd
Login-AzureRmAccount -Credential $cred
PowerShell을 통해 MyRG에 있는 VM들을 한꺼번에 순차적으로 기동하기
- ps1 스크립트 형태로 만들어 사용할 때는 "PowerShell을 통해 자동 로그인하기"를 항상 위에 먼저 넣어준다.
$rmvm = Get-AzureRmVM -ResourceGroupName MyRG $rmvm | ForEach-Object {Start-AzureRmVM -ResourceGroupName MyRG $_.Name}
PowerShell을 통해 MyRG에 있는 VM들을 한꺼번에 중지하기
- ps1 스크립트 형태로 만들어 사용할 때는 "PowerShell을 통해 자동 로그인하기"를 항상 위에 먼저 넣어준다.
$rmvm = Get-AzureRmVM -ResourceGroupName MyRG $rmvm | ForEach-Object {Stop-AzureRmVM -ResourceGroupName MyRG $_.Name -Force}