{"id":6673,"date":"2021-04-20T14:02:04","date_gmt":"2021-04-20T14:02:04","guid":{"rendered":"https:\/\/softreetechnology.com\/?p=6673"},"modified":"2021-04-20T14:07:49","modified_gmt":"2021-04-20T14:07:49","slug":"how-to-enable-and-disable-mfa-using-powershell","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/","title":{"rendered":"How to enable and disable MFA using PowerShell"},"content":{"rendered":"<p><strong>Introduction-<\/strong>In Office 365, multifactor authentication (MFA) is a security feature in which it authenticates whether the user who trying to access the exchange online is the same user who claims the account. MFA use the user&#8217;s phone number or mobile app to connect the Office 365.<\/p>\n<p><strong>Providing the steps below to enable MFA.<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Step1-<\/strong>To run Office 365 to remote areas you have to get all the policies.<\/p>\n<p>If the output is showing <strong>unrestricted<\/strong> then set the scope for the <strong>current user<\/strong>.<\/p>\n<p><strong>Step2-<\/strong>To connect the PowerShell online you have to get the credentials for Office 365<\/p>\n<p><strong>Step3-<\/strong>If <strong>MSOnline<\/strong> service is not imported in your end then you have to import the service first by using the below command. <strong>MSOnline<\/strong> service is use for connecting to office 365<\/p>\n<p><strong>Import-Module MSOnline<\/strong><\/p>\n<p><strong>Step4-<\/strong>Now create the authentication object and set the MFA status values.<\/p>\n<p><strong>Step5-<\/strong>Then set the MFA<\/p>\n<p>For single user<\/p>\n<p><strong>Get-MsolUser -UserPrincipalName $UserName | Set-MsolUser -UserPrincipalName $UserName -StrongAuthenticationRequirements $authentication <\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>For multiple user<\/p>\n<p><strong>Get-MsolUser \u2013All | Foreach{ Set-MsolUser -UserPrincipalName $_.UserPrincipalName -StrongAuthenticationRequirements $auth<\/strong><strong>entication<\/strong><strong>}<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Get-ExecutionPolicy<\/p>\n<p>Set-ExecutionPolicy Unrestricted \u2013Scope CurrentUser<\/p>\n<p>$credential = Get-Credential<\/p>\n<p>Connect-MsolService \u2013Credential $credential<\/p>\n<p>&nbsp;<\/p>\n<p>$UserName= Read-Host &#8220;Enter the username&#8221;<\/p>\n<p>&nbsp;<\/p>\n<p>$authentication= New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationRequirement<\/p>\n<p>$authentication.RelyingParty = &#8220;*&#8221;<\/p>\n<p>$authentication.State = &#8220;Enabled&#8221;<\/p>\n<p>$authentication.RememberDevicesNotIssuedBefore = (Get-Date)<\/p>\n<p>&nbsp;<\/p>\n<p>Get-MsolUser -UserPrincipalName $UserName | Set-MsolUser -UserPrincipalName $UserName -StrongAuthenticationRequirements $authentication<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>After running the script It will ask for credentials. Enter the user name(user must be tenanted administrator)<\/strong><\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-6675 size-full\" src=\"https:\/\/softreetechnology.com\/wp-content\/uploads\/2021\/04\/1-2.png\" alt=\"\" width=\"650\" height=\"541\" srcset=\"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/1-2.png 650w, https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/1-2-300x250.png 300w, https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/1-2-276x230.png 276w, https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/1-2-570x474.png 570w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<ul>\n<li>Enter the username in which you want to enable MFA.<\/li>\n<li>Then you can see a successful message.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-6676 size-full\" src=\"https:\/\/softreetechnology.com\/wp-content\/uploads\/2021\/04\/2-2.png\" alt=\"\" width=\"650\" height=\"126\" srcset=\"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/2-2.png 650w, https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/2-2-300x58.png 300w, https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/2-2-410x79.png 410w, https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/2-2-570x110.png 570w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<ul>\n<li>In the below screenshot you can check the user MFA status.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-6678 size-full\" src=\"https:\/\/softreetechnology.com\/wp-content\/uploads\/2021\/04\/3-2.png\" alt=\"\" width=\"650\" height=\"349\" srcset=\"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/3-2.png 650w, https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/3-2-300x161.png 300w, https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/3-2-410x220.png 410w, https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/3-2-570x306.png 570w, https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/3-2-370x200.png 370w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>How to disable MFA using PowerShell-<\/p>\n<p>If you want to disable the MFA you have to use the below code.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Get-MsolUser -UserPrincipalName $UserName | Set-MsolUser -StrongAuthenticationRequirements @ ()<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction-In Office 365, multifactor authentication (MFA) is a security feature in which it authenticates whether the user who trying to access the exchange online is the same user who claims the account. MFA use the user&#8217;s phone number or mobile app to connect the Office 365. Providing the steps below to enable MFA. &nbsp; Step1-To run Office 365 to remote [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6680,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[221],"tags":[],"class_list":["post-6673","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to enable and disable MFA using PowerShell - Softree Technology<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to enable and disable MFA using PowerShell - Softree Technology\" \/>\n<meta property=\"og:description\" content=\"Introduction-In Office 365, multifactor authentication (MFA) is a security feature in which it authenticates whether the user who trying to access the exchange online is the same user who claims the account. MFA use the user&#8217;s phone number or mobile app to connect the Office 365. Providing the steps below to enable MFA. &nbsp; Step1-To run Office 365 to remote [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2021-04-20T14:02:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-20T14:07:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/mfa.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to enable and disable MFA using PowerShell - Softree Technology","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/","og_locale":"en_US","og_type":"article","og_title":"How to enable and disable MFA using PowerShell - Softree Technology","og_description":"Introduction-In Office 365, multifactor authentication (MFA) is a security feature in which it authenticates whether the user who trying to access the exchange online is the same user who claims the account. MFA use the user&#8217;s phone number or mobile app to connect the Office 365. Providing the steps below to enable MFA. &nbsp; Step1-To run Office 365 to remote [&hellip;]","og_url":"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/","og_site_name":"Softree Technology","article_published_time":"2021-04-20T14:02:04+00:00","article_modified_time":"2021-04-20T14:07:49+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/mfa.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"How to enable and disable MFA using PowerShell","datePublished":"2021-04-20T14:02:04+00:00","dateModified":"2021-04-20T14:07:49+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/"},"wordCount":291,"commentCount":0,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/mfa.jpg","articleSection":["PowerShell"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/","url":"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/","name":"How to enable and disable MFA using PowerShell - Softree Technology","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/#primaryimage"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/mfa.jpg","datePublished":"2021-04-20T14:02:04+00:00","dateModified":"2021-04-20T14:07:49+00:00","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/#primaryimage","url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/mfa.jpg","contentUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2021\/04\/mfa.jpg","width":1280,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/powershell\/how-to-enable-and-disable-mfa-using-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/softreetechnology.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to enable and disable MFA using PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/softreetechnology.com\/blog\/#website","url":"https:\/\/softreetechnology.com\/blog\/","name":"Softree Technology","description":"Celebrating 10+ Years in SharePoint Consulting !","publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/softreetechnology.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/softreetechnology.com\/blog\/#organization","name":"Softree Technology","url":"https:\/\/softreetechnology.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","contentUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","width":844,"height":230,"caption":"Softree Technology"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b","name":"admin","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/softreeconsulting.com"],"url":"https:\/\/softreetechnology.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/6673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/comments?post=6673"}],"version-history":[{"count":2,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/6673\/revisions"}],"predecessor-version":[{"id":6679,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/6673\/revisions\/6679"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media\/6680"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=6673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=6673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=6673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}