FUNCTION |
POWERSHELL | SCRIPT |
Connect MSOL PowerShell to Office 365 | MSOL PowerShell | Connect-MsolService |
Set User Principal Name for a mailbox | MSOL PowerShell | Set-MsolUserPrincipalName -UserPrincipalName user@domain.onmicrosoft.com -NewUserPrincipalName user@domain.com |
Set single user password as never expire | MSOL PowerShell | Set-MsolUser –userprincipalname user@domain.com -PasswordNeverExpires $true |
Set bulk user password as never expire | MSOL PowerShell | Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $true |
Verify password never expire value | MSOL PowerShell | Get-MsolUser | fl PasswordNeverExpires, Displayname |
Get licensing information for all the users in the domain | MSOL PowerShell | Get-msoluser | Select DisplayName, UserPrincipalName, islicensed | export-csv c:\Folder\FileName.csv -notypeinformation |
To verify the Provisioning Status in all Office 365 services (EXO/SPO/LYO/APPS) | MSOL PowerShell | Get-MsolAccountSku | % { $_.ServiceStatus } |
To create a new password for a user | MSOL PowerShell | Set-MsolUserPassword -UserPrincipalName <UPN of the user> -NewPassword <password> -ForceChangePassword $<true/false> |
Enable or Disable a user’s credential in Office 365 | MSOL PowerShell | Set-MsolUser -UserPrincipalName <UPN of the user to be blocked> -blockcredential $<true/false> |
Modify password expiration period and notification days for the entire domain | MSOL PowerShell | Set-MsolPasswordPolicy -ValidityPeriod <Days> -NotificationDays <Days> -DomainName <Domain Name> |
Hide external contact(s) from global address list (GAL) in Office 365 | MSOL PowerShell | Set-MailContact -Identity <Mailbox Id> -HiddenFromAddressListsEnabled $true |
Get E-mail Forwarding details for all the blocked <disabled> users | MSOL PowerShell + Windows PowerShell | “$data=Get-MsolUser | Select BlockCredential, UserPrincipalName foreach($i in $data) { $BlockCredential=$i.BlockCredential $UPN=$i.UserPrincipalName If($BlockCredential-eq$True) { Get-Mailbox -Identity $UPN | Select-Object UserPrincipalName, Forwarding* } }” |
Enable or Disable credential for all the users in Office 365 domain | MSOL PowerShell | Get-MsolUser | Set-MsolUser -BlockCredential $True / False |
View all the users whose credentials have been blocked | MSOL PowerShell + Windows PowerShell | “$data=Get-MsolUser | Select BlockCredential, UserPrincipalName foreach($i in $data) { $BlockCredential=$i.BlockCredential $UPN=$i.UserPrincipalName If($BlockCredential-eq$True) { Get-Mailbox -Identity $UPN | Select-Object UserPrincipalName } }” |
View all the users whose Password has been set as Never Expire or not set as Never Expire and then export the results to a CSV file | MSOL Powershell | “$data=Get-MsolUser -MaxResult 3000 | Select PasswordNeverExpires, UserPrincipalName $Result=foreach($i in $data) { $PasswordNeverExpires=$i.PasswordNeverExpires $UPN=$i.UserPrincipalName If($PasswordNeverExpires-eq$True / False) { Get-MsolUser -UserPrincipalName $UPN | Select-Object DisplayName, PasswordNeverExpires } } $Result | Export-Csv C:\nirav\pswd.csv -notype” |
Get list of users with licenses assigned | MSOL Powershell | Get-msoluser -all | ForEach-Object { “=============”; $_.DisplayName; $_.licenses[0].servicestatus } |