AWS Tools for PowerShell
User Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Set an IAM Policy for an IAM User

The following commands show how to assign an IAM policy to an IAM user. The policy specified below provides the user with "Power User Access". This policy is identical to the Power User Access policy template provided in the IAM console. The name for the policy shown below follows the naming convention used for IAM policy templates such as the template for Power User Access. The convention is

<template name>+<user name>+<date stamp>

In order to specify the policy document, we use a PowerShell here-string. We assign the contents of the here-string to a variable and then use the variable as a parameter value in Write-IAMUserPolicy.

PS > $policyDoc = @" >> { >> "Version": "2012-10-17", >> "Statement": [ >> { >> "Effect": "Allow", >> "NotAction": "iam:*", >> "Resource": "*" >> } >> ] >> } >> "@ >> PS > Write-IAMUserPolicy -UserName myNewUser -PolicyName "PowerUserAccess-myNewUser-201211201605" -PolicyDocument $policyDoc ServiceResponse --------------- Amazon.IdentityManagement.Model.PutUserPolicyResponse

See Also

On this page: