When you need to run SQL queries directly against a WID DB, you can connect via SSMS. They key is to run SSMS as admin and connect to the following DB Server:

\\.\pipe\MICROSOFT##WID\tsql\query

use Windows Authentication

and there you go.

And if using powershell, connect to np:\\.\pipe\MICROSOFT##WID\tsql\query as the instance.

Also, remember, WID cannot be connect remotely, you must be on the same server.

Enjoy

Jeff