Download presentation
Presentation is loading. Please wait.
1
Office 365 PowerShell Jeremy Sublett
2
Agenda Azure AD Cmdlets
Users, licenses and other objects SharePoint Patterns and Practices (PnP) Cmdlets Lists, list items, fields and provisioning
3
Azure AD Cmdlets Cmdlets for accessing and interacting with Azure AD objects
4
Azure AD PowerShell for Graph
User/Groups Certificates AD Apps Domains Auth (OAuth2) Install-Module AzureAD Connect-AzureAD Different than MSOnline cmdlets (referred to as "Older")
5
Users and Groups Get-AzureADUser Get-AzureADUserMembership Get-AzureADGroup Get-AzureADGroupMember
6
Adding a User New-AzureADUser -UserPrincipalName -AccountEnabled $true -DisplayName "Joe Smith" -GivenName "Joe" -Surname "Smith" -MailNickName "Joe.Smith" -Department "Corporate Accounts Payable" -JobTitle "Accountant" -PasswordProfile $PasswordProfile
7
Adding a User $PasswordProfile = New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile $PasswordProfile.Password = "mynewpassword"
8
Adding a Group New-AzureADGroup -DisplayName "Dev Team" -MailEnabled $false -SecurityEnabled $true -MailNickName "NotSet" Add-AzureADGroupMember -ObjectId… -RefObjectId… Group ID User ID
9
Licenses Get-AzureADSubscribedSku Set-AzureADUserLicense
10
Licenses # Create the objects we'll need to add and remove licenses $license = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense $licenses = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses # Find the SkuID of the license we want to add - in this example we'll use the O365_BUSINESS_PREMIUM license $license.SkuId = (Get-AzureADSubscribedSku | Where-Object -Property SkuPartNumber -Value "O365_BUSINESS_PREMIUM" -EQ).SkuID # Set the Office license as the license we want to add in the $licenses object $licenses.AddLicenses = $license # Call the Set-AzureADUserLicense cmdlet to set the license. Set-AzureADUserLicense -ObjectId -AssignedLicenses $licenses
11
AzureAD verses MSOnline
AzureAD: allows user to manage Active Directory objects only, [where directory is hosted in Azure] azuread?view=azureadps-2.0 MSOnline: apart from managing Active Directory allows more administrative tasks such as Domain management, configure single sign- on etc. msonlinev1?view=azureadps-1.0
12
SharePoint PnP Cmdlets
PowerShell cmdlets for enhanced SharePoint management
13
SharePoint Patterns and Practices
Community-Driven Different from "SPO" cmdlets provided by Microsoft Excellent capabilities to manipulate lists, views and items Installation: Install-Module SharePointPnPPowerShellOnline
14
* PnP originally used "SPO" in command names
Multiple Cmdlets SharePoint Patterns and Practices ("PnP" naming in commands)* Connect-PnPOnline -Url Connect-PnPOnline -Url * PnP originally used "SPO" in command names SharePoint Online Management Shell ("SPO" naming in commands) Connect-SPOService -Url
15
Connecting via PnP Cmdlets
Site Collection Root Connect-PnPOnline -Url Subsite (Subweb) Connect-PnPOnline -Url Authenticating $creds = Get-Credentials Connect-PnPOnline -Url … -Credentials $creds Connect-PnPOnline -Url … -UseWebLogin
16
Basic SharePoint Concepts
"Site" – a container for webs Site Collection / Root Web "Web" – a location for containing document libraries and lists (sometimes called sites) /web1 /web1/childweb1 Sub Web or Child Web
17
Webs Get-PnPWebTemplates New-PnPWeb -Title "Customers Web" -Url "CustMgmt" -Description "Simple team site" -Template "STS#3" Connect-PnPOnline -Url Get-PnPSubWebs Remove-PnPWeb -Identity 81c90c36-d2e4-4e68-bc38-5af5d96303d1 Remove-PnPWeb –Url web1
18
Lists New-PnPList -Title "Customers" -Template Contacts Get-PnpList Remove-PnpList –Title "Customers"
19
Lists $x = Import-Csv -Path .\Desktop\CustList50.csv $x | ForEach-Object { Add-PnPListItem -List Customers = $_.last_name; "First Name = $_.first_name} }
20
Fields Add-PnPField -List "Customers" -DisplayName "Size" -InternalName "Size" -Type MultiChoice -AddToDefaultView -Choices "Small","Medium","Large"
21
Create View Add-PnPView -List "Customers" -Title "Simple" - Fields "Title","Company","Size"
22
Documents Add-PnpFile, Get-PnpFile, Move-PnpFile, Copy-PnpFile
Add-PnpFile -Path "c:\temp\MyDoc.txt" -Folder "Shared Documents" Get-ChildItem -Path .\Desktop\TestFolder\ | ForEach-Object { Add-PnPFile -Path $_.FullName -Folder "Shared Documents" } Get-PnPFolderItem -FolderSiteRelativeUrl "SitePages" -ItemType File Get-PnPListItem -List "Site Pages"
23
Other Interesting PnP Commands
Submit-PnpSearchQuery –Query "*Test*" Add-PnPNavigationNode -Title "Contoso" -Url " -Location "QuickLaunch" Get-PnPProvisioningTemplate -Out C:\temp\prov.xml
24
Links Azure AD Reference
directory/overview?view=azureadps-2.0 directory/importing-data?view=azureadps-2.0 PnP Reference pnpapp?view=sharepoint-ps
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.