• facebook
  • twitter
  • linkedin

Read time 3 minutes

Summary: This article explores the use of PowerShell cmdlets in Office 365 for user account management and other functions. It guides users on connecting to Office 365 via PowerShell, managing users, passwords, licenses, groups, and sites. PowerShell automation streamlines Office 365 tasks, enhances administrator efficiency, and offers comprehensive control.

This article delves into the realm of PowerShell cmdlets, demonstrating their utility in managing user accounts and executing various functions within Office 365.

To harness the power of PowerShell cmdlets in Office 365, users should start by downloading the Microsoft Online Service Sign-in Assistant for IT Professionals RTW and installing it on their systems, with a preference for the 64-bit version. Once this service is successfully integrated into your system, the next step involves downloading and installing the essential Windows Azure Active Directory Module for PowerShell.

Connect to Office 365

Initiate the Windows Azure Active Directory Module for PowerShell that you’ve installed. Then, execute the following commands to establish a connection with your Office 365 account.

$officecredentials = get-credential
connect-msolservice -credential $officecredentials

At this point, you’ll be prompted to input your Office 365 account credentials. Please provide them to establish the connection to Office 365.

Following this connection, you gain the ability to oversee various Office 365 functions related to users, groups, sites, passwords, and more. While many tasks can be handled through the Office 365 admin center, PowerShell stands out as a more professional and comprehensive approach to managing Office 365 tasks. Let’s explore a few actions that can be accomplished using Office 365 PowerShell.

Task1 – Management of Office 365 Users

  1. To get the complete list of all user mailboxes in your Office 365 account, run this command:
    Get-MsolUser | Select DisplayName, City, Department
  2. Create a new user by running this command:
    New-MsolUser -UserPrincipalName username@sharepointarena.onmicrosoft.com -DisplayName “User name” -FirstName “User first name” -LastName “User last name”
  3. To remove or restore any user mailbox of Office 365, try these cmdlets:
    Remove-MsolUser -UserPrincipalName “<email address>” -DisplayName “<display name>”
    Restore-MsolUser -UserPrincipalName “<email address>” -DisplayName “<display name>”

Note: It restores the user mailbox up to 30 days after the deletion (the default retention period). After this period, the mailbox gets deleted permanently.

For more information, get standard details on Office 365 PowerShell.

Task2 – Management of Office 365 Password and Account Settings

Another crucial task achievable through PowerShell in Office 365 involves the automated password setting and account management.

  1. To set the Office 365 account password, try this command in PowerShell.
    Set-MsolUserPassword-UserPrincipalName “<email address>” -NewPassword “New Password”
  2. To set or update the Office 365 account user principal name, use this cmdlet.
    Set-MsolUser-UserPrincipalName “<email address>” -NewUserPrincipalName “New User Principal Name”

Task3 – Management of Office 365 Licenses

You can view the licensed users, assign a license and manage the licenses of a specific user in Office 365 using PowerShell cmdlets.

  1. Run the below command in PowerShell to view all the licensed users in Office 365.
    Get-MsolUser | ft UserPrincipalName, DisplayName, *lic*
  2. To assign a license to a specific Office 365 user, run this cmdlet:
    Set-MsolUserLicense -UserPrincipalName “user name” -AddLicenses “<licensed name>”

Task4 – Management of Office 365 Groups and Sites

You can add a member to an Office 365 group using PowerShell. The commands are given as under:

Add-MsolGroupMember -GroupObjectId <groupobjectid> -GroupMemberObjectId – <groupmemberobjectid> -GroupMembertype User

To get all the commands available in Office 365, type this cmdlet:

Get-Command *msol*

Benefits of PowerShell cmdlets in Office 365

Some important advantages of using PowerShell cmdlets in Office 365 are:

  • Automates almost all Office 365 functions
  • Reduces the efforts of Office 365 administrators
  • Makes the execution of tasks more reliable and accurate
  • Offers to use services across different deployments
  • It is more comprehensive than Office 365 admin center

Hope this article is helpful to know the importance of PowerShell in Office 365.

Conclusion

PowerShell cmdlets assist administrators in efficiently managing Office 365 users, including their passwords, account settings, licenses, and more. Additionally, these cmdlets streamline the management of Office 365 groups, enhancing the effectiveness of administrators in maintaining the environment.

Related Posts