0

I am trying to open closed site using the following code

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

$URL="http://1111:39993/sites/test17081"
$spWeb = Get-SPWeb $URL

$isClosed = [Microsoft.Office.RecordsManagement.InformationPolicy.ProjectPolicy]::IsProjectClosed($spWeb)

If ($isClosed)
{
    write-host  "site is closed :" , $spWeb.url
    [Microsoft.Office.RecordsManagement.InformationPolicy.ProjectPolicy]::OpenProject($spWeb)

    $spWeb.Update()
}

it raised the following exception : (Exception calling "OpenProject" with "1" argument(s): "Sorry, this site hasn't been shared with you.")

However when I do the same but close project instead of open it, it working fine. BTY I am site collection administrator

Please advice !

1

May be there is right issue for the user running PowerShell script, Check the Permissions and try again.

  • The user who run PowerShell is site collection admin so what right permission needed ? – Mohammed Thabet Oct 5 '16 at 13:51
  • and if there is missing permission , why CloseProject() works fine with the same user ? – Mohammed Thabet Oct 5 '16 at 14:01
0

My college proposed solution for me and it working well that use elevated privilegses :

[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges(
    {

        #write code here 
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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