{"id":7281,"date":"2024-12-27T14:41:56","date_gmt":"2024-12-27T14:41:56","guid":{"rendered":"https:\/\/softreetechnology.com\/blog\/?p=7281"},"modified":"2024-12-27T14:41:57","modified_gmt":"2024-12-27T14:41:57","slug":"how-to-enable-and-disable-mfa-using-powershell-3","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/","title":{"rendered":"How To Enable And Disable MFA Using PowerShell"},"content":{"rendered":"\n<p>In Office 365, multifactor authentication (MFA) is a security feature in which it authenticates whether the user who tries 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\n\n\n<p>Providing the steps below to enable MFA,<\/p>\n\n\n\n<p><strong>Step 1<\/strong><\/p>\n\n\n\n<p>To run Office 365 to remote areas you have to get all the policies.<\/p>\n\n\n\n<p>If the output is showing unrestricted then set the scope for the current user.<\/p>\n\n\n\n<p><strong>Step 2<\/strong><\/p>\n\n\n\n<p>To connect the PowerShell online you have to get the credentials for Office 365<\/p>\n\n\n\n<p><strong>Step 3<\/strong><\/p>\n\n\n\n<p>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\n\n\n<p><strong>Import-Module MSOnline<\/strong>&nbsp;<\/p>\n\n\n\n<p><strong>Step 4<\/strong><\/p>\n\n\n\n<p>Now create the authentication object and set the MFA status values.<\/p>\n\n\n\n<p><strong>Step 5<\/strong><\/p>\n\n\n\n<p>Then set the MFA<\/p>\n\n\n\n<p>For single user,<\/p>\n\n\n\n<p>Get-MsolUser -UserPrincipalName $UserName | Set-MsolUser -UserPrincipalName $UserName -StrongAuthenticationRequirements $authentication<\/p>\n\n\n\n<p>For multiple user,<\/p>\n\n\n\n<p>Get-MsolUser \u2013All | Foreach{ Set-MsolUser -UserPrincipalName $_.UserPrincipalName -StrongAuthenticationRequirements $authentication}<\/p>\n\n\n\n<p>Get-ExecutionPolicy&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>Set-ExecutionPolicyUnrestricted\u2013ScopeCurrentUser&nbsp;&nbsp;<\/p>\n\n\n\n<p>$credential=Get-Credential&nbsp;&nbsp;<\/p>\n\n\n\n<p>Connect-MsolService\u2013Credential$credential&nbsp;&nbsp;<\/p>\n\n\n\n<p>$UserName=Read-Host&#8221;Enter the username&#8221;&nbsp;&nbsp;<\/p>\n\n\n\n<p>$authentication=New-Object-TypeNameMicrosoft.Online.Administration.StrongAuthenticationRequirement&nbsp;&nbsp;<\/p>\n\n\n\n<p>$authentication.RelyingParty =&#8221;*&#8221;&nbsp;&nbsp;<\/p>\n\n\n\n<p>$authentication.State =&#8221;Enabled&#8221;&nbsp;&nbsp;<\/p>\n\n\n\n<p>$authentication.RememberDevicesNotIssuedBefore = (Get-Date)&nbsp;&nbsp;<\/p>\n\n\n\n<p>Get-MsolUser-UserPrincipalName$UserName|Set-MsolUser-UserPrincipalName$UserName-StrongAuthenticationRequirements$authentication&nbsp;<\/p>\n\n\n\n<p>After running the script It will ask for credentials. Enter the user name(user must be tenanted administrator)<\/p>\n\n\n\n<p>Enter the username in which you want to enable MFA.<\/p>\n\n\n\n<p>Then you can see a successful message.<\/p>\n\n\n\n<p>In the below screenshot you can check the user MFA status.<\/p>\n\n\n\n<p><strong>How to disable MFA using PowerShell<\/strong><\/p>\n\n\n\n<p>If you want to disable the MFA you have to use the below code.<\/p>\n\n\n\n<p>Get-MsolUser -UserPrincipalName $UserName | Set-MsolUser -StrongAuthenticationRequirements @ ()<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Office 365, multifactor authentication (MFA) is a security feature in which it authenticates whether the user who tries 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, Step 1 To run Office 365 to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7282,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[298],"tags":[456,455,208,56,159],"class_list":["post-7281","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pnp-powershell","tag-mfa","tag-office365","tag-pnp-powershell","tag-sharepoint","tag-sharepoint-online"],"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\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/\" \/>\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=\"In Office 365, multifactor authentication (MFA) is a security feature in which it authenticates whether the user who tries 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, Step 1 To run Office 365 to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-27T14:41:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-12-27T14:41:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2024\/12\/How-To-Enable-And-Disable-MFA-Using-PowerShell-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1080\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\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=\"1 minute\" \/>\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\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/","og_locale":"en_US","og_type":"article","og_title":"How To Enable And Disable MFA Using PowerShell - Softree Technology","og_description":"In Office 365, multifactor authentication (MFA) is a security feature in which it authenticates whether the user who tries 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, Step 1 To run Office 365 to [&hellip;]","og_url":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/","og_site_name":"Softree Technology","article_published_time":"2024-12-27T14:41:56+00:00","article_modified_time":"2024-12-27T14:41:57+00:00","og_image":[{"width":1080,"height":1080,"url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2024\/12\/How-To-Enable-And-Disable-MFA-Using-PowerShell-1.png","type":"image\/png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"How To Enable And Disable MFA Using PowerShell","datePublished":"2024-12-27T14:41:56+00:00","dateModified":"2024-12-27T14:41:57+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/"},"wordCount":296,"commentCount":0,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/#primaryimage"},"thumbnailUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2024\/12\/How-To-Enable-And-Disable-MFA-Using-PowerShell-1.png","keywords":["MFA","Office365","PnP PowerShell","SharePoint","SharePoint Online"],"articleSection":["PnP PowerShell"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/","url":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/","name":"How To Enable And Disable MFA Using PowerShell - Softree Technology","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/#primaryimage"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/#primaryimage"},"thumbnailUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2024\/12\/How-To-Enable-And-Disable-MFA-Using-PowerShell-1.png","datePublished":"2024-12-27T14:41:56+00:00","dateModified":"2024-12-27T14:41:57+00:00","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/#primaryimage","url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2024\/12\/How-To-Enable-And-Disable-MFA-Using-PowerShell-1.png","contentUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2024\/12\/How-To-Enable-And-Disable-MFA-Using-PowerShell-1.png","width":1080,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/pnp-powershell\/how-to-enable-and-disable-mfa-using-powershell-3\/#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\/7281","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=7281"}],"version-history":[{"count":1,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/7281\/revisions"}],"predecessor-version":[{"id":7283,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/7281\/revisions\/7283"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media\/7282"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=7281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=7281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=7281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}