Todd Klindt Todd.klindt@sympraxisconsulting.com @toddklindt - - PowerPoint PPT Presentation

todd klindt
SMART_READER_LITE
LIVE PREVIEW

Todd Klindt Todd.klindt@sympraxisconsulting.com @toddklindt - - PowerPoint PPT Presentation

Todd Klindt Todd.klindt@sympraxisconsulting.com @toddklindt www.toddklindt.com www.toddklindt.com/MSPSUG Agenda Before you Connect Except Exchange $PSVersionTable.PSVersion Also consider adding PSReadLine if you are not on Win10


slide-1
SLIDE 1
slide-2
SLIDE 2

Todd Klindt

Todd.klindt@sympraxisconsulting.com

@toddklindt www.toddklindt.com

www.toddklindt.com/MSPSUG

slide-3
SLIDE 3

Agenda

slide-4
SLIDE 4
slide-5
SLIDE 5

Before you Connect

  • Except Exchange
  • $PSVersionTable.PSVersion
  • Also consider adding PSReadLine if you are not on Win10
  • Video walkthrough

Install Sign-in Assistant

slide-6
SLIDE 6

A Word about Passwords

$MyAccount = Get-Credential $username = admin@company.onmicrosoft.com $password = “RightHereInPlainText” $secure = $password | ConvertTo-SecureString -AsPlainText –Force $MyAccount = New-Object System.Management.Automation.PSCredential ($username, $secure)

Use an encrypted file

slide-7
SLIDE 7

Windows Credential Manager

slide-8
SLIDE 8

PowerShell

Use Credential Manager

slide-9
SLIDE 9

A Quick Word about MFA

Enable MFA at the tenant (AzureAD) level Create an app password for your account

slide-10
SLIDE 10

Connect to your Azure AD Tenant

$MyAccount = Get-PnPStoredCredential -Name TenantAdmin -Type PSCredential Connect-MsolService -Credential $MyAccount Get-MsolUSer Get-Command -Module msonline $MyAccount = Get-Credential Connect-AzureAD -Credential $MyAccount Get-AzureADUser Get-Command -Module AzureAD

slide-11
SLIDE 11

Fun Gotchas

slide-12
SLIDE 12

Don’t Try This At Home

slide-13
SLIDE 13

Connect to Skype for Business

slide-14
SLIDE 14
slide-15
SLIDE 15

Exchange Online

Just a little different

  • No cmdlets, uses Remoting
  • Limited to three sessions
  • Requires port 80
  • Close out gracefully
  • Remove-PSSession $Session
  • Supports MFA
slide-16
SLIDE 16
slide-17
SLIDE 17
slide-18
SLIDE 18

License Up That New Mailbox

slide-19
SLIDE 19

PowerShell with SharePoint Online

  • Users and groups
  • Tenants
  • Site Collections
  • Hub Sites
  • Multi-Geo

Download here

slide-20
SLIDE 20

Connect to SharePoint online

slide-21
SLIDE 21

Things to install

Install Sign-in Assistant Install MSOnline Module Install Azure AD Module Install SharePoint Online Module Install Skype for Business Online Module Office 365 PowerShell Module Installs Update the modules

slide-22
SLIDE 22

Install them all

slide-23
SLIDE 23

Updating the Modules

PowerShell to Update your PowerShell Modules

slide-24
SLIDE 24

Example script

slide-25
SLIDE 25

Real world example

Param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [string] $User ) # Add the Active Directory bits and not complain if they're already there Import-Module ActiveDirectory -ErrorAction SilentlyContinue # Add the Azure Active Directory module Import-Module MSOnline

slide-26
SLIDE 26

# Define AD group that is synced to AAD and is used for ODFB audience $syncgroupname = "CloudSync" $syncgroup = Get-ADGroup $syncgroupname # First, add the user to the group Add-ADGroupMember -Identity $syncgroupname -Members $User # Remind them to recompile their SharePoint audience Write-Host "You'll need to recompile your SharePoint audience to reflect the group change" # Sync up to Azure AD Start-ADSyncSyncCycle

slide-27
SLIDE 27

# Now tweak the user in Azure AD, First connect Connect-MsolService -Credential (Get- StoredCredential -Target Admin) # Azure AD domain suffix $aadsuffix = (Get-MsolDomain | Where-Object - Property IsDefault -Value $true -EQ).name # Get the user $aaduser = "$user@$aadsuffix"

slide-28
SLIDE 28

# Set the user's location. Without that the license will fail Set-MsolUser -UserPrincipalName $aaduser -UsageLocation “US" $license = "tkdemo:O365_BUSINESS_PREMIUM” # Set the user's license Set-MsolUserLicense -UserPrincipalName $aaduser - AddLicenses $license

slide-29
SLIDE 29

Microsoft Teams!!

  • Woo Hoo!
  • PowerShell Support
  • https://blogs.technet.microsoft.com/skypehybridguy/2017/11/07/microsoft-

teams-powershell-support/

  • For automating all those Teams Tasks
  • Install-Module MicrosoftTeams
slide-30
SLIDE 30

Flow and PowerApps

  • Flow and PowerApps
  • For both creators and Admins
  • Get list of all Flows and PowerApps
  • Kind of a janky install
  • Install-Module -Name

Microsoft.PowerApps.Administration.PowerShell

  • Install-Module -Name Microsoft.PowerApps.PowerShell -

AllowClobber

slide-31
SLIDE 31

Office 365/Unified Groups

  • No Groups module
  • MSOL / Azure
  • Exchange
  • Teams
  • PnP PowerShell
slide-32
SLIDE 32
slide-33
SLIDE 33

The Sneaky Way: CSOM with PowerShell

SharePoint 2016 Client SDK

slide-34
SLIDE 34

Top Of Script

slide-35
SLIDE 35

Get-SPOweb

http://www.sharepointnutsandbolts.com/2013/12/Using-CSOM-in- PowerShell-scripts-with-Office365.html

slide-36
SLIDE 36

More Examples

slide-37
SLIDE 37
slide-38
SLIDE 38

Patterns and Practices PowerShell (Phew!)

Github

  • https://github.com/SharePoint/PnP-PowerShell
slide-39
SLIDE 39

Favorites

  • PnPFile
  • Add-PnPFile, Copy-PnPFile
  • Find-PnPFile, Get-PnPFile
  • Move-PnPFile, Remove-PnPFile
  • Rename-PnPFile
  • Set-PnPFileCheckedIn
  • Set-PnPFileCheckedOut
  • PnPList
  • Add, Get, Set, Remove
  • Get-PnPListItem
  • Set-PnPListItem
  • Get-PnPProperty
  • Set-PnPGroupPermissions
  • Add-PnPView
  • Get-PnPField
  • Restore-PnPRecycleBinItem
  • Office 365 Groups
  • New-PnPUnifiedGroup, Remove-

PnPUnifiedGroup

  • Get-PnPUnifiedGroup, Set-

PnPUnifiedGroup

  • Get-PnPUnifiedGroupMembers
  • Get-PnPUnifiedGroupOwners
slide-40
SLIDE 40

But my Boss HATES PnP PowerShell!

Vesa Juvonen PowerShell Gallery RenCore

  • Exceptions are approved by SharePoint Engineering team
  • Can be more secure, as it can be more fine grained
slide-41
SLIDE 41

How do I keep up?

https://www.toddklindt.com/POSHOffice365Modules

slide-42
SLIDE 42
slide-43
SLIDE 43

Upload a File

https://tenant.sharepoint.com/sites/hr

slide-44
SLIDE 44

Add a Folder

Get-PnPProperty

slide-45
SLIDE 45

Get Internal Shared Files

slide-46
SLIDE 46

Get Extended File Info

Connect-PnPOnline -Url $url -Credentials MeganB $doclibs = Get-PnPList -Includes DefaultViewUrl,IsSystemList | Where-Object -Property IsSystemList -EQ -Value $false | Where-Object -Property BaseType -EQ -Value "DocumentLibrary“ Foreach ($doclib in $doclibs) { $doclibTitle = $doclib.Title $docs = Get-PnPListItem -List $DocLib $docs | ForEach-Object { Get-PnPProperty -ClientObject $_ -Property File, ContentType, ComplianceInfo} foreach ($doc in $docs) { [pscustomobject]@{Library= $doclibTitle;Filename = ($doc.File).Name;ContentType = ($doc.ContentType).Name;Label = ($doc.ComplianceInfo).ComplianceTag} }

slide-47
SLIDE 47

Bulk Undelete Files

https://sadtenant.sharepoint.com/ baduser@sadtenant.phooey

https://www.toddklindt.com/PoshRestoreSPOFiles

slide-48
SLIDE 48

New Site and Group

  • No Group, No Team, No Bueno
  • Can be Groupified later
  • Group, No Team
  • Can be Teamified later
slide-49
SLIDE 49

The Whole Enchilada

  • There is no later!
slide-50
SLIDE 50

“Save Site as Template”

slide-51
SLIDE 51

Copy Office 365 Group Permissions

slide-52
SLIDE 52
slide-53
SLIDE 53

https://www.toddklindt.com/PoshCopyO365GroupMembers

slide-54
SLIDE 54

Get All the Flows

slide-55
SLIDE 55

Get Your Flows

slide-56
SLIDE 56

Disable Flow Button

Connect-SPOService -Url https://flowhater-admin.sharepoint.com $val = [Microsoft.Online.SharePoint.TenantAdministration.FlowsPolicy]::Disabled Set-SPOSite -Identity https://flowhater.sharepoint.com/sites/SadSite - DisableFlows $val Connect-PnPOnline -Url https://flowhater.sharepoint.com/sites/SadSite - Credentials ‘SiteAdmin' Set-PnPSite -DisableFlows:$true

slide-57
SLIDE 57

And PowerApps Apps