0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Azure】PowerShellでAzureにログインできるようにしてみた #初学者

Posted at

PowerShellからAzureにログイン出来るようにしたのでメモとして残しておきます。

最新版PowerShellをダウンロード

GitHubで公開されているのでそこから最新版をダウンロードしてきます。
URLはこちら。
https://github.com/PowerShell/PowerShell/releases

{Latest}となっているものを選びましょう。
スクリーンショット 2025-03-30 141515.png

下にスクロールしていくとwindows 64bit版があったのでこちらをダウンロードしました。
スクリーンショット 2025-03-30 141703.png

PowerShellからAzureにログイン

インストールしてPowerShellを立ち上げるとダウンロードしたバージョンであることが分かります。

PowerShell 7.5.0
PS C:\Users\user>

でもこのままではAzureにログインできません。

PS C:\Users\user> Connect-AzAccount
Connect-AzAccount: The term 'Connect-AzAccount' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Azureのモジュールをインストールする必要があるようです。

PS C:\Users\user> install-Module -Name AZ

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet.
Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): A #今回は全てのモジュールをインストールするため【A】を入力。

モジュールのインストールが完了すればAzureにログインする準備は出来ました。
今回はDeviceCodeを使ってAzureに接続してみます。

PS C:\Users\user> connect-AzAccount -DeviceCode
WARNING: You may need to login again after updating "EnableLoginByWam".
Please select the account you want to login with.

[Login to Azure] To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code I8Z4LTTZ9 to authenticate.

PowerShell上に表示されたURLにアクセスします。
そうするとcodeを求められるので、こちらも表示されたコードを入力します。
スクリーンショット 2025-03-30 142839.png

ログインアカウントを聞かれます。私は既にサインイン済みのアカウントが表示されたので、そちらを選択。
スクリーンショット 2025-03-30 143016.png

【続行】を選択します。
スクリーンショット 2025-03-30 143045.png

これでAzureにログイン完了です。

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?