Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Powershell Script to List out SharePoint Site Permission Details
WhatsApp
Karthik Muthu Karuppan
Jan 27
2015
5.7
k
0
0
FindSitePermissions.
$LogTime = Get-Date -Format yyyy-MM-dd_hh-mm
$LogFile =
".\UserPermissionsDetailsPatch-$LogTime.rtf"
# Add SharePoint PowerShell Snapin
if
( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $
null
) {
Add-PSSnapin Microsoft.SharePoint.Powershell
}
$scriptBase = split-path $SCRIPT:MyInvocation.MyCommand.Path -parent
Set-Location $scriptBase
#Deleting any .rtf files in the scriptbase location
$FindRTFFile = Get-ChildItem $scriptBase\*.* -include *.rtf
if
($FindRTFFile)
{
foreach($file
in
$FindRTFFile)
{
remove-item $file
}
}
start-transcript $logfile
$siteCollection = read-host
"Enter the site collection URL "
$site = get-spsite $siteCollection
foreach($web
in
$site.allwebs)
{
$users = get-spuser -web $web.url -Limit ALL
foreach($user
in
$users)
{
write-host $User.userlogin
$permissionInfo = $web.GetUserEffectivePermissionInfo($User.userLogin)
$roles = $permissionInfo.RoleAssignments
write-host
"Now checking the permissions of the user "
$User.userLogin
" in the site "
$web.Url -fore yellow
for
($i = 0; $i -lt $roles.Count; $i++)
{
$bRoles = $roles[$i].RoleDefinitionBindings
foreach ($roleDefinition
in
$bRoles)
{
if
($roles[$i].Member.ToString().Contains(
'\'
))
{
write-host
"The User "
$user.userLogin
" has direct permissions "
$roleDefinition.Name -fore green
}
else
{
write-host
"The User "
$user.userLogin
" has permissions "
$roleDefinition.Name
" given via "
$roles[$i].Member.ToString() -fore green
}
}
}
}
}
SharePoint
Permission
Up Next
Powershell Script to List out SharePoint Site Permission Details