1

I was wondering if there is a script or two that can be run to find out all items that have specific unique permissions and also list WHO has access to the items?

I need to migrate over 3 million documents out of SP2007, but a lot of the documents may have unique, uninherited permissions and I cannot see an automated way of capturing this information.

Sorry I am new to all of this

Thanks for any advice given

1
  • Sharepoint 2007 didn' had PowerSHell support. you were using stsadm for administartion. You can use server object model with SP 2007 (inside powershell) sharepointdiary.com/2011/05/… Commented Mar 20, 2019 at 14:41

1 Answer 1

0
function Get-ItemsWithUniquePermissions(){
Param(
    [Parameter(Mandatory=$true, Position=0)]
    [ValidateNotNullOrEmpty()]
    [string]$folderPath,
    [Parameter(Mandatory=$true, Position=1)]
    [ValidateNotNullOrEmpty()]
    [string]$rootSiteUrl
)

$folder=$folderPath
$date=Get-Date -UFormat "%Y-%m-%d-%H%M"

$fileName="ItemsWithUniquePermissions$date.csv"


if(!(Test-Path $folder)){
    New-Item -Path $folder -ItemType directory
}

if(!(Test-Path $errorLog)){
    New-Item -Path $errorLog -ItemType file
}


[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$rootSite = New-Object Microsoft.SharePoint.SPSite($rootSiteUrl)



$webs=$rootSite.AllWebs

foreach($web in $webs){
    $lists=$web.lists | ?{$_.hidden -eq $false}
    foreach($list in $lists){
        $items=$list.items
        foreach($item in $items){
            if ($item.HasUniqueRoleAssignments) {
                $itemData= new-object psobject
                $itemData |Add-Member -Type NoteProperty -Name Web -Value "$($web.url)"
                $itemData |Add-Member -Type NoteProperty -Name List -Value $($list.title)
                $itemData |Add-Member -Type NoteProperty -Name Item -Value $($item.id)

                $itemData |Export-Csv -Path "$folder\$filename" -NoTypeInformation -Encoding UTF8 -Append
            }
        }

    }
}

}

Get-ItemsWithUniquePermissions -folderPath c:\temp -rootSiteUrl http://dev

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.