Office 365 Power Shell Jeremy Sublett Agenda Azure
Office 365 Power. Shell Jeremy Sublett
Agenda • Azure AD Cmdlets • Users, licenses and other objects • Share. Point Patterns and Practices (Pn. P) Cmdlets • Lists, list items, fields and provisioning
Azure AD Cmdlets for accessing and interacting with Azure AD objects
Azure AD Power. Shell for Graph • • • User/Groups Certificates AD Apps Domains Auth (OAuth 2) Install-Module Azure. AD Connect-Azure. AD • Different than MSOnline cmdlets (referred to as "Older")
Users and Groups Get-Azure. ADUser. Membership Get-Azure. ADGroup. Member
Adding a User New-Azure. ADUser -User. Principal. Name "joe. smith@contoso. com" -Account. Enabled $true -Display. Name "Joe Smith" -Given. Name "Joe" -Surname "Smith" -Mail. Nick. Name "Joe. Smith" -Department "Corporate Accounts Payable" -Job. Title "Accountant" -Password. Profile $Password. Profile
Adding a User $Password. Profile = New-Object -Type. Name Microsoft. Open. Azure. AD. Model. Password. Profile $Password. Profile. Password = "mynewpassword"
Adding a Group New-Azure. ADGroup -Display. Name "Dev Team" -Mail. Enabled $false -Security. Enabled $true -Mail. Nick. Name "Not. Set" Add-Azure. ADGroup. Member -Object. Id… -Ref. Object. Id… Group ID User ID
Licenses Get-Azure. ADSubscribed. Sku Set-Azure. ADUser. License
Licenses # Create the objects we'll need to add and remove licenses $license = New-Object -Type. Name Microsoft. Open. Azure. AD. Model. Assigned. License $licenses = New-Object -Type. Name Microsoft. Open. Azure. AD. Model. Assigned. Licenses # Find the Sku. ID of the license we want to add - in this example we'll use the O 365_BUSINESS_PREMIUM license $license. Sku. Id = (Get-Azure. ADSubscribed. Sku | Where-Object -Property Sku. Part. Number -Value "O 365_BUSINESS_PREMIUM" -EQ). Sku. ID # Set the Office license as the license we want to add in the $licenses object $licenses. Add. Licenses = $license # Call the Set-Azure. ADUser. License cmdlet to set the license. Set-Azure. ADUser. License -Object. Id "joe. smith@contoso. com" -Assigned. Licenses $licenses
Azure. AD verses MSOnline • Azure. AD: allows user to manage Active Directory objects only, [where directory is hosted in Azure] • https: //docs. microsoft. com/en-us/powershell/module/azuread/connectazuread? view=azureadps-2. 0 • MSOnline: apart from managing Active Directory allows more administrative tasks such as Domain management, configure single sign-on etc. • https: //docs. microsoft. com/en-us/powershell/azure/activedirectory/install-msonlinev 1? view=azureadps-1. 0
Share. Point Pn. P Cmdlets Power. Shell cmdlets for enhanced Share. Point management
Share. Point Patterns and Practices • Community-Driven https: //github. com/Share. Point/Pn. P-Power. Shell • Different from "SPO" cmdlets provided by Microsoft • Excellent capabilities to manipulate lists, views and items • Installation: Install-Module Share. Point. Pn. PPower. Shell. Online
Multiple Cmdlets Share. Point Patterns and Practices ("Pn. P" naming in commands)* Connect-Pn. POnline -Url https: //contoso. sharepoint. com/web 1 * Pn. P originally used "SPO" in command names Share. Point Online Management Shell ("SPO" naming in commands) Connect-SPOService -Url https: //contoso-admin. sharepoint. com https: //www. microsoft. com/en-us/download/details. aspx? id=35588
Connecting via Pn. P Cmdlets • Site Collection Root Connect-Pn. POnline -Url http: //tenantxyz. sharepoint. com • Subsite (Subweb) Connect-Pn. POnline -Url http: //tenantxyz. sharepoint. com/web 1 • Authenticating $creds = Get-Credentials Connect-Pn. POnline -Url … -Credentials $creds Connect-Pn. POnline -Url … -Use. Web. Login
Basic Share. Point Concepts "Site" – a container for webs Site Collection Root Web / "Web" – a location for containing document libraries and lists (sometimes called sites) /web 1/childweb 1 Sub Web or Child Web
Webs Get-Pn. PWeb. Templates New-Pn. PWeb -Title "Customers Web" -Url "Cust. Mgmt" -Description "Simple team site" -Template "STS#3" Connect-Pn. POnline -Url https: //contoso. sharepoint. com/Cust. Mgmt Get-Pn. PSub. Webs Remove-Pn. PWeb -Identity 81 c 90 c 36 -d 2 e 4 -4 e 68 -bc 38 -5 af 5 d 96303 d 1 Remove-Pn. PWeb –Url web 1
Lists New-Pn. PList -Title "Customers" -Template Contacts Get-Pnp. List Remove-Pnp. List –Title "Customers"
Lists $x = Import-Csv -Path. DesktopCust. List 50. csv $x | For. Each-Object { Add-Pn. PList. Item -List Customers -Values @{"Title" = $_. last_name; "First Name = $_. first_name} }
Fields Add-Pn. PField -List "Customers" -Display. Name "Size" -Internal. Name "Size" -Type Multi. Choice -Add. To. Default. View -Choices "Small", "Medium", "Large"
Create View Add-Pn. PView -List "Customers" -Title "Simple" Fields "Title", "Company", "Size"
Documents Add-Pnp. File, Get-Pnp. File, Move-Pnp. File, Copy-Pnp. File Add-Pnp. File -Path "c: tempMy. Doc. txt" -Folder "Shared Documents" -Values @{Modified="1/1/2016"} Get-Child. Item -Path. DesktopTest. Folder | For. Each-Object { Add-Pn. PFile -Path $_. Full. Name -Folder "Shared Documents" } Get-Pn. PFolder. Item -Folder. Site. Relative. Url "Site. Pages" -Item. Type File Get-Pn. PList. Item -List "Site Pages"
Other Interesting Pn. P Commands Submit-Pnp. Search. Query –Query "*Test*" Add-Pn. PNavigation. Node -Title "Contoso" -Url "http: //microsoft. com" -Location "Quick. Launch" Get-Pn. PProvisioning. Template -Out C: tempprov. xml
Links • Azure AD Reference https: //docs. microsoft. com/en-us/powershell/azure/activedirectory/overview? view=azureadps-2. 0 https: //docs. microsoft. com/en-us/powershell/azure/activedirectory/importing-data? view=azureadps-2. 0 • Pn. P Reference https: //docs. microsoft. com/en-us/powershell/module/sharepointpnp/add-pnpapp? view=sharepoint-ps
- Slides: 25