dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

ConvertTo-DbaXESession should work across domains and support alternate credentials

Open fatherjack opened this issue 2 years ago • 0 comments

Summarize Functionality

When working across domains to convert SQL trace to XE sessions there is a need to pass credentials to the target server so that ConvertTo-DbaXESession can execute Get-DbaXESession in 3 places in its code ( currently lines, 83, 89, and 116).

Currently, when logged in as [MyUser]@[ThisDomain] user and wanting to get a trace converted on a server in [OtherDomain] I use this code Get-DbaTrace -SqlInstance [TargetServer].[OtherDomain] -SqlCredential (Get-Credential [OtherDomain Credential])| ConvertTo-DbaXESession -OutputScriptOnly

but this results in WARNING: [11:50:35][Get-DbaXESession] Failure | Login failed for user '[ThisDomain]\[MyUser]'. followed by some TSQL that is potentially the desired output but as there are warnings it isnt trusted.

Is there a command that is similiar or close to what you are looking for?

Yes

Technical Details

If we can pass a -SqlCredential parameter to ConvertTo-DbaXESession like this Get-DbaTrace -SqlInstance [TargetServer].[OtherDomain] -SqlCredential (Get-Credential [OtherDomain Credential]) | ConvertTo-DbaXESession -SqlCredential (Get-Credential [OtherDomain Credential]) -OutputScriptOnly and this is passed in to the calls to Get-DbaXESession on the appropriate lines with Get-DbaXESession -SqlInstance $server -Session $PSBoundParameters.Name -SqlCredential $PSBoundParameters.SqlCredential then the desired functionality should be achieved.

fatherjack avatar Jun 22 '22 12:06 fatherjack