There are more AWS SDK examples available in the AWS Doc SDK Examples
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/BobsMFADevicethat is associated with the userBob.aws iam deactivate-mfa-device \ --user-nameBob\ --serial-numberarn:aws:iam::210987654321:mfa/BobsMFADeviceThis command produces no output.
For more information, see Using multi-factor authentication (MFA) in AWS in the AWS IAM User Guide.
-
For API details, see DeactivateMfaDevice
in AWS CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell V4
-
Example 1: This command disables the hardware MFA device associated with the user
Bobthat has the serial number123456789012.Disable-IAMMFADevice -UserName "Bob" -SerialNumber "123456789012"Example 2: This command disables the virtual MFA device associated with the user
Davidthat has the ARNarn: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 theGet-IAMVirtualMFADevicecommand. Before you can create a new virtual MFA device for the same user, you must delete the old one by using theRemove-IAMVirtualMFADevicecommand.Disable-IAMMFADevice -UserName "David" -SerialNumber "arn:aws:iam::210987654321:mfa/David"-
For API details, see DeactivateMfaDevice in AWS Tools for PowerShell Cmdlet Reference (V4).
-
- Tools for PowerShell V5
-
Example 1: This command disables the hardware MFA device associated with the user
Bobthat has the serial number123456789012.Disable-IAMMFADevice -UserName "Bob" -SerialNumber "123456789012"Example 2: This command disables the virtual MFA device associated with the user
Davidthat has the ARNarn: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 theGet-IAMVirtualMFADevicecommand. Before you can create a new virtual MFA device for the same user, you must delete the old one by using theRemove-IAMVirtualMFADevicecommand.Disable-IAMMFADevice -UserName "David" -SerialNumber "arn:aws:iam::210987654321:mfa/David"-
For API details, see DeactivateMfaDevice in AWS Tools for PowerShell Cmdlet Reference (V5).
-