Posts

Showing posts from 2022

SharePoint PnP Management Shell - Permissions Consent

Image
The SharePoint PnP Management Shell is a PowerShell module that is a part of the open-source Microsoft 365 Community projects led by Microsoft Engineers and Microsoft MVPs (e.g. https://github.com/waldekmastykarz , https://github.com/erwinvanhunen ). It complements Microsoft Online SharePoint Management Shell by adding over 500 PowerShell commandlets to query and manage various elements of SharePoint Online, many of which have no equivalents in other tools or in the user interface (e.g. Export-PnPTaxonomy , Get-PnPAvailableClientSideComponents , Get-PnPCustomAction , Get-PnPEventReceiver , Get-PnPJavaScriptLink , Get-PnPSearchConfiguration , Get-PnPSiteTemplate ). However, in order to use the module, it needs to be granted permission consent to the Azure Enterprise Application “ PnP Management Shell ” that is used by default by the module to access Microsoft Graph functionality in the tenant. The following is an example of the types of permissions that are requested: Such pe

Useful SharePoint PowerShell Snippets

SharePoint Update ```PowerShell if($env:USERNAME -notlike "*spfarm*"){     Write-Warning "Please, execute the script as SPFarm account";     return -1; } $thisFile = (Get-Item $PSCommandPath); $logsFolder = "$($thisFile.Directory.Parent.FullName)\Logs"; New-Item $logsFolder -ErrorAction Ignore; Start-Transcript "$($logsFolder)\$(Get-Date -Format 'yyyy-MMdd-HHmm')-$($thisFile.BaseName)-$($env:COMPUTERNAME).log" -IncludeInvocationHeader; try {     try{         Add-PSSnapin Microsoft.SharePoint.PowerShell;         Write-Host "`r`n`r`nUpgrading content databases`r`n`r`n" -ForegroundColor Yellow;         foreach($db in (Get-SPContentDatabase)){             Write-Host "Upgrading DB: $($db)";             Upgrade-SPContentDatabase $db -Confirm:$false -ErrorAction Continue;         }     } catch {         $Error | % { Write-Error $_; };         $Error.Clear();     }     #Install-SPApplication