user guide powershell office365 azure - vodafone india · user guide – powershell ... windows...

20
User Guide PowerShell Office365 Azure Prepared by: Vodafone Shared Services Limited This document is meant for Vodafone cloud customers only and is confidential & legally privileged. Please do not reproduce copy or disclose this document or its contents with any third party/ies nor use it for purposes other than this document has been shared for.

Upload: dinhngoc

Post on 24-Jul-2018

272 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

User Guide – PowerShell

Office365 Azure

Prepared by: Vodafone Shared Services Limited

This document is meant for Vodafone cloud customers only and is confidential & legally privileged.

Please do not reproduce copy or disclose this document or its contents with any third party/ies nor use it

for purposes other than this document has been shared for.

Page 2: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

2 | P a g e

Table of Contents

INTRODUCTION ........................................................................................................................................... 3

CONNECT TO OFFICE 365 POWERSHELL ............................................................................................... 4

GET DETAILS ............................................................................................................................................... 6

GET ALL USERS DETAILS .............................................................................................................................. 6

GET OFFICE 365 PLAN DETAILS .................................................................................................................... 7

GET GROUP DETAILS .................................................................................................................................... 8

GET DETAILS OF ADMINISTRATIVE ROLES ...................................................................................................... 9

MANAGE USERS ....................................................................................................................................... 10

MANAGE GROUPS .................................................................................................................................... 15

MANAGE USER ROLES ............................................................................................................................ 19

REFERENCE LINKS ................................................................................................................................... 20

Page 3: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

3 | P a g e

Introduction

PowerShell (also known as Windows PowerShell) is a command-line environment

that's designed specifically for system administration. PowerShell helps IT professionals

and power users control and automate the administration of the Windows operating

system and applications, such as Office 365.

The most basic part of PowerShell is called a cmdlet (pronounced command-let).

Cmdlets allow you to do things in the Office 365 PowerShell environment like

adding users to your Office 365 organization, managing Office 365 license assignments

and know which mailboxes are inactive.

Windows PowerShell allows you to manage Office 365 using a single point of

administration by using automated and scripted actions and streamlines your daily work.

Some Benefits of PowerShell

1. Windows PowerShell Can Reveal "Hidden" Information Not Available in the

Admin Center

2. Office 365 has Features That You Can Only Configure by Using Windows

PowerShell

3. Windows PowerShell Excels at Carrying Out Bulk Operations

4. Windows PowerShell is Great at Filtering Data

5. Windows PowerShell Makes It Easy to Print or Save Data

6. Windows PowerShell Lets You Do "Cross-Product" Management

In this document we are going to see some basic commands which will help to

administrate Office 365

Page 4: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

4 | P a g e

Connect to Office 365 PowerShell

1. Open Azure PowerShell module.

Page 5: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

5 | P a g e

2. Store Office 365 user credentials in $liveid veriable.

$liveid = Get-credentials

3. Type Office 365 admin user credentials

4. Connect Msonline service with saved credentials

Connect-Msolservice –Credentials $liveid

5. Now we can start with managing Office 365

Page 6: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

6 | P a g e

Get Details

Get all users details

1. To get user details use following command.

Get-MsolUser [-All] [-City <string>] [-Country <string>] [-Department

<string>] [-DomainName <string>] [-EnabledFilter <string>] [-

HasErrorsOnly] [-LicenseReconciliationNeededOnly] [-ReturnDeletedUsers]

[-State <string>] [-Synchronized] [-TenantId <Guid>] [-Title <string>] [-

UnlicensedUsersOnly] [-UsageLocation <string>] [<CommonParameters>]

Page 7: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

7 | P a g e

2. To view and export all the details of users use the following command

Get-msoluser | export-csv d:\mehta.csv

Get Office 365 plan details

1. Get Office 365 plan (Account SKU) details

Get-MsolAccountsku

Page 8: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

8 | P a g e

Get group details

1. To retrieve groups from the Office 365 services use following command.

Get-MsolGroup

2. To retrieve group members use following command.

$Group = Get-MsolGroup | Where-Object {$_.DisplayName -eq "Group

Name"}

Get-MsolGroupMember -GroupObjectId $Group.ObjectId

Page 9: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

9 | P a g e

Get details of Administrative roles

1. To retrieve a list of administrator roles use following command.

Get-Msolrole

2. To retrieve all members of the specified role use following command.

$Role = Get-MsolRole | Where-object {$_.Name –eq "Company

Administrator"}

Get-MsolRoleMember -RoleObjectId $role.ObjectId

Page 10: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

10 | P a g e

Manage Users

1. To create new user use following command

New-MsolUser -DisplayName <string> -UserPrincipalName <string> [-

AlternateEmailAddresses <string[]>] [-BlockCredential <Boolean>] [-City

<string>] [-Country <string>] [-Department <string>] [-Fax <string>] [-

FirstName <string>] [-ForceChangePassword <Boolean>] [-ImmutableId

<string>] [-LastName <string>] [-LicenseAssignment <string[]>] [-

LicenseOptions <LicenseOption[]>] [-MobilePhone <string>] [-Office

<string>] [-Password <string>] [-PasswordNeverExpires <Boolean>] [-

PhoneNumber <string>] [-PostalCode <string>] [-PreferredLanguage

<string>] [-State <string>] [-StreetAddress <string>] [-

StrongPasswordRequired <Boolean>] [-TenantId <Guid>] [-Title <string>] [-

UsageLocation <string>] [<CommonParameters>

Page 11: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

11 | P a g e

2. Modify user attribute

Set-MsolUser [-AlternateEmailAddresses <string[]>] [-BlockCredential

<Boolean>] [-City <string>] [-Country <string>] [-Department <string>] [-

DisplayName <string>] [-Fax <string>] [-FirstName <string>] [-ImmutableId

<string>] [-LastName <string>] [-MobilePhone <string>] [-ObjectId <Guid>]

[-Office <string>] [-PasswordNeverExpires <Boolean>] [-PhoneNumber

<string>] [-PostalCode <string>] [-PreferredLanguage <string>] [-State

<string>] [-StreetAddress <string>] [-StrongPasswordRequired <Boolean>]

[-TenantId <Guid>] [-Title <string>] [-UsageLocation <string>] [-

UserPrincipalName <string>] [<CommonParameters>]

3. To change user password use following command.

Set-MsolUserPassword -userPrincipalName [email protected] -

NewPassword “Pass@123”

Page 12: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

12 | P a g e

4. To remove User use following command.

Remove-MsolUser -UserPrincipalName <string> [-RemoveFromRecycleBin

<switch>] [-Force] [-TenantId <Guid>] [<CommonParameters>]

5. To restore User use following command.

$DelUser = Get-MsolUser -UserPrincipalName [email protected] -

ReturnDeletedUsers

Restore-MsolUser -ObjectId $DelUser.ObjectId

6. To set single user password as never expire use following command.

Set-MsolUser –userprincipalname [email protected] -

PasswordNeverExpires $true

Page 13: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

13 | P a g e

7. To Set bulk user password as never expire use the following command

Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $true

8. To Remove bulk user password as never expire use the following command

Get-MSOLUser | Set-MsolUser -PasswordNeverExpires $False

9. To Verify password never expire value use the following command

Get-MsolUser | fl PasswordNeverExpires, Displayname

Page 14: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

14 | P a g e

10. Modify password expiration period and notification days for the entire domain

Set-MsolPasswordPolicy -ValidityPeriod <Days> -NotificationDays <Days> -

DomainName <Domain Name>

Page 15: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

15 | P a g e

Manage Groups

1. To add a new security group to the Azure AD use following command.

New-MsolGroup -DisplayName "Marketing" -Description "Marketing

Executives"

2. To add members to a security group use following command. The new members

can be either users or other security groups.

$User = Get-Msoluser | Where-Object {$_.DisplayName -eq "User’s Display

Name"}

$Group = Get-MsolGroup | Where-Object {$_.DisplayName -eq "Group

Name"}

Page 16: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

16 | P a g e

Add-MsolGroupMember -groupObjectid $Group.ObjectId -

GroupMemberType "User" -GroupMemberObjectId $User.ObjectId

3. To remove a member from a security group use following command.

$User = Get-Msoluser | Where-Object {$_.DisplayName -eq "User’s Display

Name"}

$Group = Get-MsolGroup | Where-Object {$_.DisplayName -eq "Group

Name"}

Page 17: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

17 | P a g e

Remove-MsolGroupMember -groupObjectid $Group.ObjectId -

GroupMemberType "User" -GroupMemberObjectId $User.ObjectId

4. To update the properties of a security group use following command.

Set-MsolGroup [-Description <string>] [-DisplayName <string>] [-

ManagedBy <string>] [-ObjectId <Guid>] [-TenantId <Guid>]

[<CommonParameters>]

$Group = Get-MsolGroup | Where-Object {$_.DisplayName -eq "Group

Name"}

Set-MsolGroup -ObjectId $Group.ObjectId -Description "Management"

Page 18: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

18 | P a g e

Set-MsolGroup -ObjectId $Group.ObjectId -DisplayName "Cloud

Management Team"

5. To delete a group from the Microsoft Azure Active Directory use following

command.

Remove-MsolGroup -ObjectId <Guid> [-Force] [-TenantId <Guid>]

[<CommonParameters>]

$Group = Get-MsolGroup | Where-Object {$_.DisplayName -eq "Group

Name"}

Remove-MsolGroup -objectid $group.objectId

Page 19: User Guide PowerShell Office365 Azure - Vodafone India · User Guide – PowerShell ... Windows PowerShell allows you to manage Office 365 using a single point of ... To set single

19 | P a g e

Manage User Roles

1. To add a member to Administrative role use following command

Add-MsolRoleMember -RoleName "Company Administrator" -

RoleMemberEmailAddress [email protected]

2. To remove a user from an administrator role use following command.

Remove-MsolRoleMember -RoleName "Company Administrator" -

RoleMemberType User -RoleMemberEmailAddress [email protected]