0

I am trying modify content located in an unattached content DB. But I am having trouble accessing the lists.

Here is my powershell script code:

$db=Get-SPContentDatabase -ConnectAsUnattachedDatabase  -DatabaseName wss_content_abc -DatabaseServer SP13DEV $site=$db.Sites[0]

$site.RootWeb.Lists

the last line gives me this error message:

The following exception occurred while trying to enumerate the collection: "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))". At line:1 char:1 + $site.RootWeb.Lists + ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException + FullyQualifiedErrorId : ExceptionInGetEnumerator

I double checked that my account is a DB owner

0

the code below fixed the problem:

$webApp = $db.WebApplication
$user = $env:USERDOMAIN+"\"+$env:USERNAME
$webApp.GrantAccessToProcessIdentity($user)

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.