Use DeactivateMfaDevice with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use DeactivateMfaDevice with a CLI

The following code examples show how to use DeactivateMfaDevice.

CLI
AWS CLI

To deactivate an MFA device

This command deactivates the virtual MFA device with the ARN arn:aws:iam::210987654321:mfa/BobsMFADevice that is associated with the user Bob.

aws iam deactivate-mfa-device \ --user-name Bob \ --serial-number arn:aws:iam::210987654321:mfa/BobsMFADevice

This command produces no output.

For more information, see Using multi-factor authentication (MFA) in AWS in the AWS IAM User Guide.

PowerShell
Tools for PowerShell

Example 1: This command disables the hardware MFA device associated with the user Bob that has the serial number 123456789012.

Disable-IAMMFADevice -UserName "Bob" -SerialNumber "123456789012"

Example 2: This command disables the virtual MFA device associated with the user David that has the ARN arn:aws:iam::210987654321:mfa/David. Note that virtual MFA device is not deleted from the account. The virtual device is still present and appears in the output of the Get-IAMVirtualMFADevice command. Before you can create a new virtual MFA device for the same user, you must delete the old one by using the Remove-IAMVirtualMFADevice command.

Disable-IAMMFADevice -UserName "David" -SerialNumber "arn:aws:iam::210987654321:mfa/David"