Skatterbrainz / CMHealthCheck

ConfigMgr Health Check Reporting PowerShell functions
MIT License
32 stars 11 forks source link

Issues connecting to SQL server instance even when account has full access - Found #54

Closed smalaut closed 4 years ago

smalaut commented 4 years ago

When running Get-CMHealthCheck I am receiving an "ERROR/EXCEPTION: general unhandled exception" in the logs immediately after "getting sql server info" completes

Invoke-CMHealthCheck failed to complete, so I started troubleshooting by running Get-CMHealthCheck only. This failed as well; confirming my issue was on the front end.

After verifying with DBA team my access is full admin for the server and instance and owner for the CM Databases, i went through the Get-CMHealthCheck code and determined line 170 parsing by instance and removing the instance from the database name, but Invoke-DbaQuery (line 181) fails to query because parameter -SqlInstance doesnt work without the DB instance declared with the DB server

Fails to Complete: Invoke-DbaQuery -SqlInstance "SERVER" -Database "DATABASE" -Query "select * from dbo.v_r_system" -EnableException -ErrorAction SilentlyContinue

Completes Successfully: Invoke-DbaQuery -SqlInstance "SERVER/INSTANCE" -Database "DATABASE" -Query "select * from dbo.v_r_system" -EnableException -ErrorAction SilentlyContinue

If this portion of the Get-CMHealthCheck fails to complete, the script will exit after line 181.

I'm still stepping through the code where it connects to the SQL Server If there is more code involving the DB instance, I will simply declare the DB instance as a variable at line 170 during parsing for later use in the code.

I appreciate you providing this module and all it entails. I hope this helps others and is worth you checking into.

smalaut commented 4 years ago

sorry, so many edits

Skatterbrainz commented 4 years ago

Thank you!! I'm looking into this now.

Skatterbrainz commented 4 years ago

What version of the module are you using?

Skatterbrainz commented 4 years ago

Closing since there hasn't been a response in 23 days