Skip to content

Instantly share code, notes, and snippets.

param (
[Parameter(Mandatory = $true)]
[string] $domain
)
$adminSiteURL = "https://$domain-Admin.SharePoint.com"
$TenantURL = "https://$domain.sharepoint.com"
$dateTime = "_{0:MM_dd_yy}_{0:HH_mm_ss}" -f (Get-Date)
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
@reshmee011
reshmee011 / Find where Everyone has been granted permissions
Last active November 11, 2024 17:09
Find where Everyone has been granted permissions
param (
[Parameter(Mandatory = $true)]
[string] $domain
)
Clear-Host
$properties=@{SiteUrl='';SiteTitle='';ListTitle='';SensitivityLabel='';Type='';RelativeUrl='';ParentGroup='';MemberType='';MemberName='';MemberLoginName='';Roles='';};
$adminSiteURL = "https://$domain-Admin.SharePoint.com"
@reshmee011
reshmee011 / GetHasUniqueRoleAssignments_REST
Created August 5, 2024 11:21
GetHasUniqueRoleAssignments_REST
param(
[Parameter(Mandatory)]
[string]$SiteUrl
)
if(!$siteUrl)
{
$siteUrl = Read-Host -Prompt "Enter the site collection";
}
@reshmee011
reshmee011 / GetHasUniqueRoleAssignments_PnP
Last active August 7, 2024 08:30
GetHasUniqueRoleAssignments
#Parameters
$tenantUrl = Read-Host -Prompt "Enter tenant collection URL";
$dateTime = (Get-Date).toString("dd-MM-yyyy-hh-ss")
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
$fileName = "SharedLinks-PnP" + $dateTime + ".csv"
$ReportOutput = $directorypath + "\Logs\"+ $fileName
@reshmee011
reshmee011 / gist:5864ab7e4a6a453f2e343d06d72ed70c
Created August 2, 2024 09:30
delete_m365_ConnectedTeamSite
Try {
$AdminCenterURL="https://contoso-admin.sharepoint.com/"
$SiteURL = "https://contoso.sharepoint.com/sites/test"
#Connect to SharePoint admin site
Connect-PnPOnline -Url $AdminCenterURL -Interactive
#Get the SharePoint Online site
$Site = Get-PnPTenantSite -Identity $SiteURL -errorAction Ignore
#Delete the Office 365 Group
Remove-PnPMicrosoft365Group -Identity $Site.GroupId -errorAction Ignore
@reshmee011
reshmee011 / gist:55c75ad5466e23d21e45fd108beda1b5
Created August 2, 2024 09:21
Get_Delete_NonDirect_SharingLinks
param(
[Parameter(Mandatory)]
[ValidateSet('Yes','No')]
[string]$ExcludeDirectSharingLink,
[Parameter(Mandatory)]
[ValidateSet('Yes','No')]
[string]$DeleteSharingink,
[Parameter(Mandatory)]
[string]$SiteUrl
)
@reshmee011
reshmee011 / storagemetrics_site
Last active August 19, 2024 10:31
StorageMetrics
$SiteUrl = Read-Host "Enter site collection URL"
$dateTime = (Get-Date).toString("dd-MM-yyyy-hh-ss")
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
$fileName = "storageMetrics" + $dateTime + ".csv"
$outputPath = $directorypath + "\"+ $fileName
# Create storageMetrics.csv if not present
if (-not (Test-Path $outputPath)) {
@reshmee011
reshmee011 / GetSharingLink_Csom_with_PnP
Created July 22, 2024 22:46
Get Sharing Links combining CSOM and PNP
@reshmee011
reshmee011 / effectivepermissions
Last active April 18, 2025 10:29
effectivepermissionsforuser
#Parameters
$tenantUrl = Read-Host -Prompt "Enter tenant URL";
$dateTime = (Get-Date).toString("dd-MM-yyyy-hh-ss")
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
$fileName = "EffectivePermissionsReport-" + $dateTime + ".csv"
$ReportOutput = $directorypath + "\Logs\"+ $fileName
$userName = Read-Host -Prompt "Enter User Name";
#Connect to PnP Online
Connect-PnPOnline -Url $tenantUrl -Interactive
@reshmee011
reshmee011 / GetfilefolderItemcountTenant
Created July 6, 2024 11:59
Get Total Count of SharePoint Files, Folders, and Items with PnP PowerShell
#Parameters
$SiteURL="https://contosoonline-admin.sharepoint.com/"
$dateTime = (Get-Date).toString("dd-MM-yyyy")
$invocation = (Get-Variable MyInvocation).Value
$directorypath = Split-Path $invocation.MyCommand.Path
$fileName = "SiteStats-" + $dateTime + ".csv"
$OutPutView = $directorypath + "\Logs\"+ $fileName
$Excludedsites =@("https://contosoonline.sharepoint.com/sites/ACT-TrunkDemo-OpenAccess","https://contosoonline.sharepoint.com/teams/TrunkDemo","https://contosoonline.sharepoint.com/sites/Test-OpenAccess"
,"https://contosoonline.sharepoint.com/teams/Test1","https://contosoonline.sharepoint.com/sites/d-intranet",