Total Pageviews

Showing posts with label office. Show all posts
Showing posts with label office. Show all posts

Monday, June 3, 2019

[Powershell] Managing O365 with Powershell

1) Installing the O365 online module

  • Download Powershell online module from this link : http://aka.ms/t01i1o
  • Under Microsoft Online Services Sign-In Assistant for IT Professionals RTW, click Download.
  • select the en\msoidcl_64.msi check box, click Next, and then click Save.Wait for the download to finish.When the download finishes, click Run.
  • In the Microsoft Online Services Sign-in Assistant Setup wizard, click I accept the terms in the license Agreement and Privacy Statement, and then click Install.If a User Account Control dialog box appears, click Yes.
  • On the Completed the Microsoft Online Services Sign-in Assistant Setup Wizard page, click Finish.
  • Then Right click on Start and click Windows PowerShell (Admin)
  • At the prompt, type Install-ModuleMSOnline command.
  • If prompted to install the NuGet provider, type Y and press ENTER.
  • If prompted to install the module from PSGallery, type Y and press ENTER
2) Create new users and assign licenses

  • At the Powershell, type the following command to connect
Connect-MsolService
  • In the Enter Credentials dialog box sign in

2.1) Create New User

New-MsolUser -UserPrincipalName Catherine@LODSA904072.onmicrosoft.com -DisplayName "Catherine Richard" -FirstName "Catherine" -LastName"Richard" -Password 'Pa55w.rd' -ForceChangePassword $false -UsageLocation "CH" 

2.2) Checking the un-licensed user

Get-MsolUser -UnlicensedUsersOnly

2.3) View the available licenses

Get-MsolAccountSku

2.4) Add Licenses to a user

Set-MsolUserLicense UserPrincipalName  catherine@LODSA904072.onmicrosoft.com AddLicenses "LODSAxxxxxx:ENTERPRISEPREMIUM"

2.5) Prevent a user from signing in


Set-MsolUser -UserPrincipalNameCatherine@LODSA904072.onmicrosoft.com -BlockCredential $true

2.6) To allow a user to sign in


Set-MsolUser -UserPrincipalNameCatherine@LODSA904072.onmicrosoft.com -BlockCredential $false

2.7) Delete a user

Remove-MsolUser -UserPrincipalNameCatherine@LODSA904072.onmicrosoft.com -Force

2.8) view the Deleted Users 

Get-MsolUser -ReturnDeletedUsers

2.9) Restore a deleted user

Restore-MsolUser -UserPrincipalNameCatherine@LODSA904072.onmicrosoft.com

2.10) view the active users list

Get-MsolUser


3) Modify user accounts

3.1) To bulk import several users from a comma-separated value (CSV) file

Import-Csv -PathC:\labfiles\O365Users.csv | ForEach-Object { New-MsolUser -UserPrincipalName$_."UPN" -FirstName $_."FirstName" -LastName $_."LastName" -DisplayName$_."DisplayName" -BlockCredential $False-ForceChangePassword $False -Password$_."Password" -PasswordNeverExpires$True -Title $_."Title" -Department$_."Department" -Office $_."Office" -PhoneNumber $_."PhoneNumber" -MobilePhone $_."MobilePhone" -StreetAddress $_."StreetAddress" -City$_."City" -State $_."State" -PostalCode$_."PostalCode" -Country $_."Country" }

It is recommended that you use the type/text feature in a Notepad first and from there to copy and then paste this code into your PowerShell session.


4) Configure groups and group membership


4.1) Create a group

New-MsolGroup -DisplayName "Marketing" -Description "Marketing department users"

4.2) Configure a variable for the group add user to the group

$MktGrp = Get-MsolGroup | Where-Object{$_.DisplayName -eq "Marketing"}

$Catherine = Get-MsolUser | Where-Object{$_.DisplayName -eq "Catherine Richard"}

Add-MsolGroupMember -GroupObjectId$MktGrp.ObjectId -GroupMemberType "User"-GroupMemberObjectId $Catherine.ObjectId


4.3) To verify the members of the group



Get-MsolGroupMember -GroupObjectId$MktGrp.ObjectId


5) Configure user passwords

5.1) Set Passwords

Set-MsolUserPassword -UserPrincipalName"Tameka@LODSA904072.onmicrosoft.com" -NewPassword 'Pa55w.rd'

5.2) Set password to never expire

Get-MsolUser | Set-MsolUser -PasswordNeverExpires $false


6) Manage service administration 

6.1) Assigning Roles

Add-MsolRoleMember -RoleName "Service Support Administrator" -RoleMemberEmailAddress"Sallie@LODSA904072.onmicrosoft.com"

Add-MsolRoleMember -RoleName "Company Administrator" -RoleMemberEmailAddress"Amy@LODSA904072.onmicrosoft.com"

6.2) Get the members who has Service Support Administrator role assigned

$role = Get-MsolRole -RoleName "Service Support Administrator"

Get-MsolRoleMember -RoleObjectId$role.ObjectId


Azure Pricing

  Azure offers pay-as-you-go and reserved instances for pricing. Azure Pricing Factors: Resource size and resource type. Different Azure loc...