Knowledge BaseInstalling MSO module and Office 365 powershell commands to troubleshoot user and password issues
W P Staff asked 6 years ago

What are some commands that i should know in order to troubleshoot user and password issues in Office 365?

2 Answers
W P Staff answered 6 years ago

It’s extremely easy to get started using PowerShell with SharePoint Online or Office 365. Within a few simple steps and a few minutes you could be writing your very own PowerShell code for Office 365. For this you will need:

  • A Windows computer with a 64-bit operating system. Ideally this will have Windows 7 or higher.
  • An Office 365 subscription. A trial subscription will do fine

Download and install these packages on your computer:

Launch a PowerShell window as an Administrator Execute these lines of code: Set-ExecutionPolicy RemoteSigned Import-Module Microsoft.PowerShell.Utility Import-Module MSOnline -force Import-Module MSOnlineExtended -force Import-Module Microsoft.Online.SharePoint.PowerShell -force sharepointonlinepowershell-1   Next execute: $credential = Get-Credential This will prompt you for a username and password. Enter your Office 365 username and password then click OK:  sharepointonlinepowershell-2   Finally to connect to Office 365 execute: Connect-MsolService -Credential $credential sharepointonlinepowershell-3 As a simple test you could check the Office 365 domain to which the session is connected using this command: Get-MsolDomain sharepointonlinepowershell-4 In order to manually sync the directory changes, follow the following steps: Open PowerShell Type: Set-ExecutionPolicy Unrestricted and hit return. Type: Import-Module DirSync and hit return. Type: Start-OnlineCoexistenceSync and hit return.Start-OnlineCoexistenceSyncNow that you have successfully forced the Directory Sync with Office 365 for changes. You may now want to check what’s synced and if it at all worked. Open the MIIS Client: “C:\Program Files\Windows Azure Active Directory Sync\SYNCBUS\Synchronization Service\UIShell\miisclient.exeStart-OnlineCoexistenceSync StatusOn the main screen that opens by default, you’ll see what all has been synced, and its detailed result. There are different section to this page. Clicking on any of the underlined item will show its details. If for any reason it doesn’t open the default screen (shown above), you can open it by clicking the Operations button on the top left side of the screen.  
-Connect to Service Connect-MsolService -Export all users Get-MsolUser -All | select userprincipalname,immutableid | Out-File c:\users.txt Set-MsolUser -UserPrincipalName -ImmutableId b610M4VThEqOHyxiDPFDJQ== -ImmutableId is the objectGUID: from the Msol directory -Get List of users that did not sync yet Get-MsolUser -All | Where-Object{$_.lastdirsynctime -eq $null} | select displayname, userprincipalname | epcsv C:\list.csv -Force removal from Recycling bin Get-MsolUser -ReturnDeletedUsers -All | Remove-MsolUser -RemoveFromRecycleBin -Force -Start Sync Start-OnlineCoexistenceSync   

W P Staff answered 6 years ago

Connect to Exchange Online

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

When done: Remove-PSSession $Session