| by Arround The Web | No comments

11 Basic PowerShell Office 365 Commands

Office 365 is a productivity application suite. It comprises apps such as Word, PowerPoint, or Excel. It is available on all devices. It has two versions, Personal and Home. The Personal version is designed for single users while the Home version is designed for more than one family member.

Quick Outline:

PowerShell Office 365 Commands

Conclusion

PowerShell Office 365 Commands

PowerShell has a dedicated set of Office 365 commands. These commands help manage the Office 365 operations.

1. Get-MsolUser

The Get-MsolUser command gets an individual or list of users from the Azure Active Directory. Individual users can be retrieved by specifying the user by its ObjectID or UserPrincipalName parameter.

Example:

This example will get the list of all Office 365 users:

Get-MsolUser *

 
To get all the users from Azure Active Directory, first, use the Get-MsolUser command and specify the asterisk (*).

2. New-MsolUser

The New-MsolUser command creates a new user account in the Active Directory domain. It is a part of the Azure Active Directory module.

Example:

This example will create a new user in Azure Active Directory:

New-MsolUser -UserPrincipalName "UserPrincipalName" -DisplayName "John Doe" -FirstName "John" -LastName "Doe"

 
To create a new user in the Azure Active Directory:

    • First, place the New-MsolUser
    • Then, specify the principal username to the -UserPrincipalName
    • After that, specify the display name to the -DisplayName parameter, first name to the -FirstName parameter, and last name to the -LastName

3. Set-MsolUserPassword

The Set-MsolUserPassword command resets the Office 365 user password. This cmdlet can only be implemented for those users who have standard identities.

Example:

This example will reset the Office 365 user account password:

Set-MsolUserPassword -UserPrincipalName "UserPrincipalName" -NewPassword "NewPassword"

 
To reset the password of the Office 365 user account:

    • First, place the Set-MsolUserPassword command and specify the user principal name to the -UserPrincipalName
    • Then, specify the new password to the -NewPassword

4. Remove-SPOUser

It removes a user account from a SharePoint site collection. For instance, it can remove a specific user or all users at once from a group.

Example:

This example will remove a user from all SharePoint sites:

Get-SPOSite | ForEach {Remove-SPOUser -Site $_.Url -LoginName "LoginNameOrEmail"}

 
To remove a user from all SharePoint sites:

    • First, place the Get-SPOSite command and pipe it to the ForEach commands query.
    • In the ForEach command query, first, place the Remove-SPOUser command and then provide the site URL using the -Site
    • After that, provide the login name or email to the -LoginName

5. Get-MsolGroup

The Get-MsolGroup command gets an individual or list of groups from the Azure Active Directory. It gets the details of the groups in Azure Active Directory. It outputs details such as display name, objectID, and description.

Example:

This example will get all the groups in Azure Active Directory:

Get-MsolGroup

 

6. Add-MsolGroupMember

The Add-MsolGroupMember command adds a member or group as a member to an existing security group or a site collection.

Example:

This example will add a new member to an existing group:

Add-MsolGroupMember -GroupObjectId "Group-Object-ID" -GroupMemberObjectId "Group-Member-Object-Id" -GroupMembertype "User"

 
To add a member to the group:

    • First, place the Add-MsolGroupMember command and provide the group object ID to the -GroupObjectId
    • Then, provide the group member object ID to the -GroupMemberObjectId parameter, and the member type to the -GroupMembertype

7. Remove-MsoLGroupMember

The Remove-MsoLGroupMember removes a member from an existing security group or a site collection.

Example:

This example will remove a user from a group:

$Group-ID = Get-MsolGroup -SearchString "Group-Member-Name"

 
First, create a variable, get the specified group and store it to the variable:

$User-ID = Get-MsolUser -UserPrincipalName "User-Principal-Name"

 
Create another variable, get the specified user and store it to the variable:

Remove-MsoLGroupMember -GroupObjectId $Group-ID -GroupMemberType User -GroupMemberObjectId $User-ID

 
Lastly, use the Remove-MsoLGroupMember command. Then, specify the variable that has stored the group value. After that, specify the user type to the -GroupMemberType parameter and assign the variable that stored the user details to the -GroupMemberObjectId parameter.

8. Connect-MsolService

The Connect-MsolService command creates or initiates a connection with the Azure Active Directory.

Example:

This example will connect to the Office services:

Connect-MsolService –Credential <Office-365-Instance-Credentials>

 
To create a connection with the Office 365 services:

    • First, place the Connect-MsolService
    • Then, specify the credentials using the -Credential

9. New-SPOSite

The New-SPOSite command creates a SharePoint site collection list for the existing company. In case the deleted sites collection exists in the recycle bin then the creation of the SharePoint site collection will fail.

Example:

This example will create a SharePoint site collection list:

New-SPOSite -Url "SharePoint-Site-URL" -Owner "Owner-Email" -StorageQuota "2000" -Title "Title-Of-Presentation"

 
To create a new SharePoint sites collection:

    • First, place the New-SPOSite command and specify the SharePoint site URL to the -URL
    • Then, specify the owner email using the -Owner parameter, and specify the storage quota using the -StorageQuota
    • Lastly, provide the title for the site collection to the -Title

10. Get-Mailbox

The Get-mailbox command gets the MailBox objects, such as quota settings, or email addresses.

Example 1:

This example will retrieve all mailbox reports:

Get-Mailbox | Get-MailboxStatistics

 
To get all mailbox reports, first, use the Get-Mailbox command and pipe it to the Get-MailboxStatistics command.

Example 2:

This example will get the complete mailbox details associated with the specified email address:

Get-Mailbox email-address

 
To get the mailbox details, simply provide the email address to the Get-Mailbox command.

11. Get-Command

The Get-Command command gets the list of cmdlets associated with the specified module. For instance, it can get the Office 365 commands associated with the MSOnline module.

Example 1:

This example will get the commands associated with the MSOnline module:

Get-Command -Module MSOnline

 
To get the MSOnline commands:

    • First, specify the Get-Command
    • Then, specify the MSOnline module to the -Module

Example 2:

This example will get the commands associated with the AzureAD module:

Get-Command -Module AzureAD

 
Similarly, to get the AzureAD commands:

    • First, specify the Get-Command
    • Then, specify the AzureAD module to the -Module

Conclusion

Office 365 consists of productivity apps, such as Word, PowerPoint, or Outlook. Microsoft Office 365 can be managed via PowerShell. PowerShell has a set of dedicated commands to manage Office 365 operations. The most commonly used Office 365 commands include Get-MsolUser, New-MsolUser, Set-MsolUserPassword, or Remove-SPOUser.

Share Button

Source: linuxhint.com

Leave a Reply