mirror of
https://github.com/admindroid-community/powershell-scripts.git
synced 2025-12-17 16:35:19 +00:00
Get All Sharing Links in SPO
Added function call for auto-module installation
This commit is contained in:
parent
2e5dd05feb
commit
245e06e50b
@ -1,7 +1,7 @@
|
|||||||
<#
|
<#
|
||||||
=============================================================================================
|
=============================================================================================
|
||||||
Name: Find All Sharing Links in SharePoint Online Using PowerShell
|
Name: Find All Sharing Links in SharePoint Online Using PowerShell
|
||||||
Version: 1.0
|
Version: 1.1
|
||||||
Website: o365reports.com
|
Website: o365reports.com
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
@ -18,9 +18,16 @@ Script Highlights:
|
|||||||
9. Compatible with certificate-based authentication (CBA).
|
9. Compatible with certificate-based authentication (CBA).
|
||||||
10.The script is scheduler friendly.
|
10.The script is scheduler friendly.
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~
|
|
||||||
|
Change Log
|
||||||
|
~~~~~~~~~~
|
||||||
|
|
||||||
|
V1.0 (Jun 10, 2025) - File created
|
||||||
|
V1.1 (Jun 12, 2025) - Added function call for PnP PowerShell module installation
|
||||||
|
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~
|
||||||
Make sure the app registration used for certificate based authentication is granted with Application permissions
|
Make sure the app registration used for certificate based authentication is granted with Application permissions
|
||||||
for "Files.Read.All" and "Sites.Read.All" to ensure it can retrieve the required details. Else, you will get the
|
for "Files.Read.All" and "Sites.Read.All" to ensure it can retrieve the required details. Else, you will get the
|
||||||
following error:"Get-PnPFileSharingLink: Either scp or roles claim need to be present in the token."
|
following error:"Get-PnPFileSharingLink: Either scp or roles claim need to be present in the token."
|
||||||
@ -53,7 +60,8 @@ Param
|
|||||||
Function Installation-Module
|
Function Installation-Module
|
||||||
{
|
{
|
||||||
$Module = Get-InstalledModule -Name PnP.PowerShell -MinimumVersion 1.12.0 -ErrorAction SilentlyContinue
|
$Module = Get-InstalledModule -Name PnP.PowerShell -MinimumVersion 1.12.0 -ErrorAction SilentlyContinue
|
||||||
If($Module -eq $null){
|
If($Module -eq $null)
|
||||||
|
{
|
||||||
Write-Host SharePoint PnP PowerShell Module is not available -ForegroundColor Yellow
|
Write-Host SharePoint PnP PowerShell Module is not available -ForegroundColor Yellow
|
||||||
$Confirm = Read-Host Are you sure you want to install module? [Yy] Yes [Nn] No
|
$Confirm = Read-Host Are you sure you want to install module? [Yy] Yes [Nn] No
|
||||||
If($Confirm -match "[yY]")
|
If($Confirm -match "[yY]")
|
||||||
@ -68,7 +76,6 @@ Function Installation-Module
|
|||||||
Exit
|
Exit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Write-Host `nConnecting to SharePoint Online...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#SPO Site connection
|
#SPO Site connection
|
||||||
@ -79,6 +86,7 @@ Function Connection-Module
|
|||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[String] $Url
|
[String] $Url
|
||||||
)
|
)
|
||||||
|
Write-Host `nConnecting to SharePoint Online...
|
||||||
if(($AdminName -ne "") -and ($Password -ne "") -and ($ClientId -ne ""))
|
if(($AdminName -ne "") -and ($Password -ne "") -and ($ClientId -ne ""))
|
||||||
{
|
{
|
||||||
$SecuredPassword = ConvertTo-SecureString -AsPlainText $Password -Force
|
$SecuredPassword = ConvertTo-SecureString -AsPlainText $Password -Force
|
||||||
@ -232,7 +240,7 @@ Function Get-SharedLinks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Installation-Module
|
||||||
$TimeStamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
|
$TimeStamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
|
||||||
$ReportOutput = "$PSScriptRoot\SPO_SharingLinks_Report_ $TimeStamp.csv"
|
$ReportOutput = "$PSScriptRoot\SPO_SharingLinks_Report_ $TimeStamp.csv"
|
||||||
$Global:ItemCount = 0
|
$Global:ItemCount = 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user