Basic Office365 Users and Group Management with PowerShell

The script comments will be enought to explain each step.  Its kind of Hello World scripts.  But may help someone for copy paste šŸ™‚

# First Get the Stuff you need. You do not need a server.  Windows 7, Windows 8 is good enought šŸ™‚ But 64Bit.
#Connecting with Office 365
$CRed = Get-Credential
Connect-MsolService -Credential $CRed

#Listing Users
Get-MsolUser | Select UserPrincipalName, DisplayName, ObjectId

#Listing New User
New-MsolUser -UserPrincipalName "" -DisplayName "FirstName LastName" -FirstName "FirstName" -LastName "LastName"

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

#Sending to REcyle Bin
Remove-MsolUser -UserPrincipalName ""

#Restoring the User from Recyle Bin
Restore-MsolUser -UserPrincipalName ""

#Sending to Permanently Removing
Remove-MsolUser -UserPrincipalName "" -RemoveFromRecycleBin -Force

#Findig User
Get-MsolUser | ? DisplayName -eq "FirstName LastName" 
Get-MsolUser | ? UserPrincipalName -eq ""

#Getting and chaning User information.  Assigning Usage Location to assing Licneses
$TestUser = Get-MsolUser | ? UserPrincipalName -EQ ""
Set-MsolUser -ObjectId $TestUser.ObjectId -UsageLocation "US"
Set-MsolUser -ObjectId $TestUser.ObjectId -DisplayName "Changed First, LastName" -FirstName "NewFirstName" -LastName "NewLastName"

#Display Licenses
Get-MsolUser | ft displayname, Licenses

#List the Office 365 Subscription or Sku

#Set the License for User (This will assign all the Available Licenses)
Set-MsolUserLicense -ObjectId $TestUser.ObjectId -AddLicenses (Get-MsolAccountSku).AccountSkuId
Set-MsolUserLicense -UserPrincipalName $TestUser.UserPrincipalName -AddLicenses (Get-MsolAccountSku).AccountSkuId

#DisplayUser Information
Get-MsolUser | ft displayname, Licenses

#List All Plans
Get-MsolAccountSku | Where-Object {$_.SkuPartNumber -eq "ENTERPRISEPACK"} | ForEach-Object {$_.ServiceStatus}

#Making a Sub Option object for Selective values
$Options = New-MsolLicenseOptions -AccountSkuId (Get-MsolAccountSku).AccountSkuId -DisabledPlans SHAREPOINTWAC, EXCHANGE_S_ENTERPRISE

#Assigning it user object 
Set-MsolUserLicense -UserPrincipalName $TestUser.UserPrincipalName -LicenseOptions $Options -Verbose

#Creating a New Office 365 Group 
$Group = New-MsolGroup -DisplayName "ATM" -Description "ATM Users"
#Getting the Group
$Group = Get-MsolGroup | ? DisplayName -EQ "ATM"
#Adding Member to Group
Add-MsolGroupMember -GroupObjectId $Group.ObjectId -GroupMemberObjectId $TestUser.ObjectId
Get-MsolGroupMember -GroupObjectId $Group.objectId

#Reading Properties of Users in a Group
Get-MsolGroupMember -GroupObjectId $Group.ObjectId -All | Select ObjectId, DisplayName, EmailAddress

#REmvoing Group Peramentnly - not Recylebin here šŸ™‚
Remove-MsolGroup -ObjectId $Group.ObjectId

#Sampe CSV
#Blank CSV

#Build Import Users from CSV (Please Remove Formatting if it does not work :))
Import-Csv -Path c:\Users.csv | ForEach-Object 
        New-MsolUser -UserPrincipalName $_."UPN"   -AlternateEmailAddresses $_."AltEmail" 
                    -FirstName $_."FirstName"     -LastName $_."LastName" 
                    -DisplayName $_."DisplayName" -BlockCredential $False 
                    -ForceChangePassword $False   -LicenseAssignment $_."LicenseAssignment" 
                    -Password $_."Password"       -PasswordNeverExpires $True 
                    -Title $_."Title"             -Department $_."Department" 
                    -Office $_."Office"           -PhoneNumber $_."PhoneNumber" 
                    -MobilePhone $_."MobilePhone" -Fax $_."Fax" 
                    -StreetAddress $_."StreetAddress" -City $_."City" 
                    -State $_."State"                 -PostalCode $_."PostalCode" 
                    -Country $_."Country"             -UsageLocation $_."UsageLocation" 

Office365 and SharePoint Online

My Own Words

Office365 is a Microsoft Hosted Cloud based solutions that allows small to medium sized companies to quickly setup and use the Microsoft Information Worker Technologies (SharePoint, Exchange, Lynch, Project and Microsoft Office).  Office365 allows these organization to save cost of servers, maintenance, support.  It works great for people on the go and is available on every platform (PC, Mobile and Web).  You are connected all the time.  SharePoint Online is one of the services of Office 365.  Microsoft Maintains Office365 and data is placed geographically dispersed data centers that allows you to be highly available with 99.99% confirmed uptime.  There are different plans for Office365.  E1, E1, P1, P2.  These plans are based on company size like 8 to 10 People company, 1-25 sized company, 25-100 to more.  You pay different prices for different plans e.g. P1 is 4 USD Per Person Per Month.  P2 and 8 USD and go on.  for more information you can use or

Microsoft has recently upgraded Offce365 to 2013 version of SharePoint, Lynch, Exchange and Project.  With Respect to Integration of SharePoint on premises with SharePoint online.  it is good for organization which has lot of people on the move or external users and they don’t have access to Organization so you can setup a "Hybrid" deployment.  You can use Sandbox Solutions to bring data in from Office365 based SharePoint online sites.  You can not develop any Server Side apps for SharePoint online.