Skip to content

Instantly share code, notes, and snippets.

@reshmee011
reshmee011 / effectivepermissions
Created July 10, 2024 20:38
effectivepermissionsforuser
#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 = "EffectivePermissionsReport-" + $dateTime + ".csv"
$ReportOutput = $directorypath + "\Logs\"+ $fileName
$userName = "i:0#.f|membership|test.test@contoso.co.uk"
#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",
#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-" + $dateTime + ".csv"
$ReportOutput = $directorypath + "\Logs\"+ $fileName
#Connect to PnP Online
Connect-PnPOnline -Url $tenantUrl -Interactive
#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-" + $dateTime + ".csv"
$ReportOutput = $directorypath + "\Logs\"+ $fileName
#Connect to PnP Online
Connect-PnPOnline -Url $tenantUrl -Interactive
#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-" + $dateTime + ".csv"
$ReportOutput = $directorypath + "\Logs\"+ $fileName
#Connect to PnP Online
Connect-PnPOnline -Url $tenantUrl -Interactive
@reshmee011
reshmee011 / Query_Permissions_SharingLinks
Created April 29, 2024 22:49
Query Permissions Unique Permissions Sharing links SharePoint Online PowerShell
@reshmee011
reshmee011 / StrippingHTML file
Last active December 28, 2017 07:21
Stripping HTML from text in SSRS reports
Public Function StripHTML(ByVal sInput As String) As String
IF sInput IsNot Nothing Then
IF(sInput <>"") Then
Dim objRegExp AS NEW System.Text.RegularExpressions.Regex("<(.|\n)+?>")
sInput = Replace(sInput, "<BR>", Chr(10))
sInput = Replace(sInput, "<br>", Chr(10))
sInput = Replace(sInput, "<br/>", Chr(10))
sInput = Replace(sInput,"&#160;", " ")
sInput = Replace(sInput, "<li>", "-")
BEGIN TRAN
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tmp_table_value') and xtype='U')
drop table #tmp_table_value
CREATE TABLE #tmp_table_value
([table_id] [int] NOT NULL,
[value_date] [datetime] NOT NULL,
[raw_value] [decimal](12, 6) NULL
)
@reshmee011
reshmee011 / deleteversions.ps1
Created April 22, 2017 10:46
Delete all list Item versions from site and sub sites using CSOM and PowerShell
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
Set-Location $PSScriptRoot
$pLoadCSOMProperties=(get-location).ToString()+"\Load-CSOMProperties.ps1"
. $pLoadCSOMProperties
Function DeleteVersionsFromLists($web, $versionCount)
{
# Set up key variables
$subscrName="<name of your Azure subscription>" -- "Visual Studio Premium with MSDN"
$rgName="<your resource group name>" -- "SharePoint-2013"
$locName="<the Azure location of your resource group>" -- "WestEurope"
$dnsName="<unique, public domain name label for the SharePoint server>" --"sp2013-app-01"
# Set the Azure subscription
Get-AzureRmSubscription -SubscriptionName $subscrName | Select-AzureRmSubscription
# Get the Azure storage account name