
Hi @Ritesh Sharma ,
Welcome to Q&A forum!
You can make it using PowerShell.
1, Grants a direct Permission Level to the given user for all sites.
#Parameters
$TenantAdminURL="https://tenant-admin.sharepoint.com"
$UserAccount = "******@tenant.com"
#Get Credentials to Connect
$Cred = Get-Credential
Try {
#Connect to Tenant Admin
Connect-PnPOnline -Url $TenantAdminURL -Credentials $Cred
#Get All Site collections - Exclude: Seach Center, Mysite Host, App Catalog, Content Type Hub, eDiscovery and Bot Sites
$Sites = Get-PnPTenantSite | Where -Property Template -NotIn ("SRCHCEN#0", "REDIRECTSITE#0","SPSMSITEHOST#0", "APPCATALOG#0", "POINTPUBLISHINGHUB#0", "EDISC#0", "STS#-1")
#Loop through each Site Collection
ForEach ($Site in $Sites)
{
Try {
#Connect to the Site
Connect-PnPOnline -Url $Site.Url -Credentials $Cred
#Permission Level to Grant
$PermissionLevel = "Contribute"
#grant permission Level to the user
Set-PnPWebPermission -User $UserAccount -AddRole $PermissionLevel
}
Catch {
write-host -f Red "Error Adding User to the Site: $($Site.URL)" $_.Exception.Message
}
}
}
Catch {
write-host -f Red "Error:" $_.Exception.Message
}
You can set the user who needs to add permissions by modifying the $UserAccount
parameter, and set the permissions granted to the user by modifying the $PermissionLevel
parameter.
2, PowerShell script to retrieve a list of all sites and export it to a CSV file.
#Config Variables
$TenantSiteURL = "https://tenant-admin.sharepoint.com/"
$CSVFilePath = "C:\Temp\AllSitesData.csv"
#Connect to Tenant Admin Site
Connect-PnPOnline -Url $TenantSiteURL -Interactive
#Get All Site collections data and export to CSV
Get-PnPTenantSite -Detailed | Select Title, URL, Owner, LastContentModifiedDate, WebsCount, Template, StorageUsage | Export-Csv -path $CSVFilePath -NoTypeInformation
You will get a csv file containing all site information.
For more information, please refer to:
Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
Hope this is helpful.
Your recognition is my honor.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.