MFA
4 TopicsUsing SharePoint Client Side Object Model with PowerShell and Multifactor Authentication
There is a technique to connect to SharePoint Online with PowerShell when Multi-factor Authentication(MFA) is enabled. https://technet.microsoft.com/en-us/library/fp161372.aspx There is a very limited list of SharePoint Online cmdlets https://technet.microsoft.com/en-us/library/fp161364.aspx I would like to leverage the client side object model to access objects like the webs(spweb) and lists(splist). https://dev.office.com/sharepoint/docs/sp-add-ins/complete-basic-operations-using-sharepoint-client-library-code Is there a technique( or example) to use my identity/credentials after I have authenticated with Multifactor Authentication with Microsoft.SharePoint.Client.ClientContext?Solved25KViews0likes7CommentsHow to traverse SharePoint site collection with Multi Factor Authentication (MFA) enabled?
I have a Winforms app that displays a SharePoint site collection and document libraries in a TreeView control with hierarchy according to the site level. I use the following code for account with MFA enabled AuthenticationManager authManager = new AuthenticationManager(); using (ClientContext clientContext = authManager.GetWebLoginClientContext(siteUrl)) { Web web = clientContext.Web; WebCollection site = web.GetSubwebsForCurrentUser(null); clientContext.Load(site, we => we.Include(w => w.Url, w => w.Title)); clientContext.ExecuteQuery(); teamSites = site.ToDictionary(w => w.Url, w => w.Title); teamSites = teamSites.OrderBy(kvp => kvp.Value).ToDictionary(k => k.Key, k => k.Value); ListCollection libraries = web.Lists; clientContext.Load(libraries, l => l.Include(li => li.DefaultViewUrl, li => li.BaseType, li => li.Title, li => li.BaseTemplate, li => li.Hidden)); clientContext.ExecuteQuery(); documentLibraries = libraries.Where(lib => lib.BaseType == BaseType.DocumentLibrary && lib.Hidden == false && lib.BaseTemplate == 101).ToList(); } The team site URL will be added to each TreeNode in my TreeView, whenever user clicks on a TreeNode, it will need to load the sub-sites and document libraries using the above method. However, every time it loads, the pop up shows and disappears because user is already logged in. Is there anyway to prevent it popping up every single time user clicks on the site TreeNode?2.2KViews0likes5CommentsActivate SharePoint online Site Collection feature across all sites in a MFA enabled O365 tenant
Has anyone tried to activate a site collection level feature across all sites in MFA enabled SP Online environment ? I'm getting the following error Error ------------------------------------------------------------------------------------------------------- Connect-SPOService : The sign-in name or password does not match one in the Microsoft account system. At line:55 char:1 + Connect-SPOService -URL $AdminSiteURL -Credential $Credential + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Connect-SPOService], IdcrlException + FullyQualifiedErrorId : Microsoft.SharePoint.Client.IdcrlException,Microsoft.Online.SharePoint.PowerShell.ConnectSPOService Get-SPOSite : No connection available. Use Connect-SPOService before running this CmdLet. At line:58 char:19 + ForEach($Site in (Get-SPOSite -Limit ALL)) + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-SPOSite], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Online.SharePoint.PowerShell.GetSite ---------------------------------------------------------------------------------------------------------------- Script ------------------- Add-Type -Path 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll' Add-Type -Path 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll' Add-Type -Path 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.UserProfiles.dll' Function Activate-SPOFeature { Param ($SiteURL,$FeatureGuid) Try { #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Credential.Username, $Credential.Password) $Ctx.Credentials = $Credentials $Site=$Ctx.Site #Get the Feature $Feature = $Site.Features.GetById($FeatureGuid) $Ctx.Load($Feature) $Ctx.ExecuteQuery() #Activate the feature if its not activated already Write-Host "Activating Feature $($FeatureStatus.DisplayName) in Site $SiteURL" if($Feature.DefinitionId -eq $null) { #sharepoint online powershell open in client application $Site.Features.Add($FeatureGuid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None) | Out-Null $Ctx.ExecuteQuery() Write-Host "`t Feature Activated!" -ForegroundColor Green } else { Write-host "`t Feature is Already Active on the Site collection!" -ForegroundColor Yellow } } Catch { write-host "Error Activating Feature: $($_.Exception.Message)" -foregroundcolor Red } } #Parameters to Activate Feature $AdminSiteURL = "https://testdomain-admin.sharepoint.com/" $FeatureGuid= [System.Guid] ("8a4b8de2-6fd8-41e9-923c-c7c3c00f8295") #Get Credentials to connect #$Credential = Get-Credential $user = 'me@test.onmicrosoft.com' $Password = Read-Host -Prompt 'Please enter your password' -AsSecureString $Credential = New-Object System.Management.Automation.PSCredential -ArgumentList $User, $Password #Connect To SharePoint Online Admin Center Connect-SPOService -URL $AdminSiteURL -Credential $Credential #Get All Site collection and loop through ForEach($Site in (Get-SPOSite -Limit ALL)) { #Activate Feature Activate-SPOFeature -Site $Site.URL -FeatureGuid $FeatureGuid }2.1KViews0likes0Commentssharepoint online user profile editing through powershell with MFA
I have several scripts to edit user profile fields through Powershell without active MFA. Sure I can have a user with a complex password outside MFA but I don't want that. Can anyone point me to one script that works with MFA? It's a sharepoint online system. Thanks a lot, Nuno1.8KViews0likes2Comments