LoginSignup
1
0

More than 3 years have passed since last update.

AWSのIAMユーザー一覧をAWS Tools for PowerShell Coreで取得

Last updated at Posted at 2019-10-02

メモとして。

AWS Tools for PowerShell Core環境の構築

Windows 10にPowerShell Core for Windowsをインストール。

PowerShell Core 6を起動し、AWS Tools for PowerShell Coreをインストール。

PS> Install-Module -Name AWSPowerShell.NetCore -AllowClobber

AWS Tools for PowerShell Core環境の確認

ExecutionPolicyがRemoteSignedになっていることを確認。

PS> Get-ExecutionPolicy
RemoteSigned

AWSPowerShell.NetCoreが読み込み可能になっていることを確認。

PS> Get-Module -ListAvailable

    Directory: C:\Users\tsuka\OneDrive\ドキュメント\PowerShell\Modules

ModuleType Version    Name                                PSEdition ExportedCommands
---------- -------    ----                                --------- ----------------
Binary     3.3.590.0  AWSPowerShell.NetCore               Desk

IAMユーザーの取得

モジュールの読み込みと確認。AWS Toolsは自動的には読み込まれない。

PS> Import-Module AWSPowerShell.NetCore
PS> Get-Module                                                                                           
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     3.3.590.0  AWSPowerShell.NetCore               {Add-AASScalableTarget, Add-ACMCertificateTag, Add-ADSConfig…

認証情報の登録と確認。一度やればいい(アクセスキーやシークレットキーを新しくしたときはやり直す)。

PS> Set-AWSCredential -AccessKey XXXXXXXXXXXXXXXXXXXX -SecretKey XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -StoreAs MyAwsCred
PS C:\Users\tsuka> Get-AWSCredential -ListProfileDetail                                                                 
ProfileName StoreTypeName         ProfileLocation
----------- -------------         ---------------
MyAwsCred   NetSDKCredentialsFile

認証情報の読み込み。

PS> Set-AWSCredential -ProfileName MyAwsCred

IAMユーザーの取得。UserNameCreateDateフィールドの表にして表示している。

PS> Get-IAMUsers | Select-Object -Property UserName,CreateDate | Format-Table                           
UserName                      CreateDate
--------                      ----------
AWS-SecretManager-User        2019/05/14 16:52:26
CircleCI                      2019/04/19 18:06:15
tsukamoto                     2019/06/04 15:16:40

参考

1
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
1
0