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]


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

1 Answer 1


the code below fixed the problem:

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

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.