This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set variables | |
$clientId = "{id of your registered app}" | |
$clientSecret = "{secret of your registered app}" | |
$realm = "{id of the tenant}" # could be found in the registered app in Azure Active Directory | |
$principal = "00000003-0000-0ff1-ce00-000000000000" # this is the SharePoint resource | |
$targetHost = "{SharePoint root of the tenant}" # example: mytenant.sharepoint.com | |
# url used for the rest call later to test the access |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$policy = New-AzureADPolicy ` | |
-Definition @('{"TokenLifetimePolicy":{"Version":1,"AccessTokenLifetime":"00:10:00","MaxAgeSessionSingleFactor":"00:10:00"}}') ` | |
-DisplayName "WebPolicyScenario" ` | |
-IsOrganizationDefault $true ` | |
-Type "TokenLifetimePolicy" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Find the n-th occurence of a pattern in a string | |
#> | |
function IndexOfNth | |
{ | |
param ( | |
[string]$String, | |
[string]$Pattern, | |
[int]$Occurence |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$web = Get-PnPWeb -Includes RoleDefinitions | |
$readerRole = $roleDefinitions.GetByType([Microsoft.SharePoint.Client.RoleType]::Reader) | |
(Get-PnPContext).Load($readerRole) | |
Invoke-PnPQuery | |
$readerRole.Name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<span id="csvViewsMonthsForPagesInSiteUrl" class="ms-cui-img-32by32 ms-cui-img-cont-float" onclick='triggerCsvSearch("ViewsMonthsSitePages");'> | |
<img src="/_layouts/15/1033/images/formatmap32x32.png" style="top: -69px; left: -511px" /> | |
</span> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host | |
Write-Host "Groups Overview" | |
Write-Host "===============" | |
Write-Host | |
$groups = Get-PnPGroup | |
foreach ($group in $groups) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$field = Get-PnPField -List "Documents" -Identity "Users" -Includes FieldTypeKind | |
$field.FieldTypeKind = [Microsoft.SharePoint.Client.FieldType]::User | |
$field.Update() | |
Invoke-PnPQuery |