-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-PnPAccessRequestDetails.ps1
48 lines (36 loc) · 1.97 KB
/
Get-PnPAccessRequestDetails.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function Get-PnPAccessRequestDetails {
$webs = Get-PnPSubWeb -Includes HasUniqueRoleAssignments, RequestAccessEmail, UseAccessRequestDefault , MembersCanShare, AssociatedMemberGroup.AllowMembersEditMembership, AssociatedMemberGroup -Recurse -IncludeRootWeb
$Data = @()
Foreach ($web in $webs ) {
#Access Request details
$HasUniqueRoleAssignments = $Web.HasUniqueRoleAssignments
$RequestAccessEmail = $Web.RequestAccessEmail
$UseAccessRequestDefault = $Web.UseAccessRequestDefault
$AllowMembersEditMembership = $Web.AssociatedMemberGroup.AllowMembersEditMembership
$MembersCanShare = $web.MembersCanShare
#Send Data to object array
$Data += New-Object psobject -Property $([Ordered]@{
site = $web.Url
UniquePermission = $HasUniqueRoleAssignments # This is the permission inheritance status ON/OFF
EmailAddress = $RequestAccessEmail # These is the email id who will get the access request.
AccessRequestStatus = $UseAccessRequestDefault #this is the "Allow access request Toggle ON/OFF"
MembersCanSHareFiles = $AllowMembersEditMembership # Allow members to share the site and individual files and folders.
MembersCanShare = $MembersCanShare # Allow members to invite others to the site members group, alertstest Members
})
}
#Display Array Data
$Data
}
#Parameters
$site = "https://fudsk.sharepoint.com/sites/apisite"
$Csv = "C:\Temp\report.csv"
try {
#Connect to the sharepoint site where you want to pull the report from.
Connect-PnPOnline -url $site -Credentials $cred -Verbose
#Function call
Get-PnPAccessRequestDetails | Export-Csv -Path $Csv
Write-Host "Exported succesfully!" -ForegroundColor green
}
catch {
write-host -f Red "Exporting report!" $_.Exception.Message
}