Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write-DbaDbTableData - "Exception occurred while trying to enumerate the collection" error #60

Open
SteveHindle opened this issue Apr 3, 2024 · 0 comments

Comments

@SteveHindle
Copy link

I have the following code that I use to retrieve some TempDB space details on an AG:

$DataDriveTable = Invoke-DbaQuery -SqlInstance $SQLInstance -Database TempDB -Query $SelectDriveQuery -EnableException

$DataDriveTable | ConvertTo-DbaDataTable | Write-DbaDataTable -SqlInstance $SQLInstance -Database master -Table "TempDBDriveInfo" -EnableException

I started to receive this intermittent error:

The following exception occurred while trying to enumerate the collection: "The target database, 'XXX', is participating in an availability group and is currently not accessible for queries. Either data movement is suspended or the availability replica is not enabled for read access. To allow read-only access to this and other databases in the availability group, enable read access to one or more secondary availability replicas in the group. For more information, see the ALTER AVAILABILITY GROUP statement in SQL Server Books Online."."

I can't understand why it is reading other user databases in the AG as I either specify TempDB or master only? I don't touch user databases or their properties.

Does anyone know why this may be happening?

Thanks

Steve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant