# The following exception occurred while trying to enumerate the collection: Access is denied

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 ## 1 Answer the code below fixed the problem: $webApp = $db.WebApplication$user = $env:USERDOMAIN+"\"+$env:USERNAME
$webApp.GrantAccessToProcessIdentity($user)