-
-
Couldn't load subscription status.
- Fork 847
Description
Verified issue does not already exist?
I have searched and found no existing issue
What error did you receive?
Read-DbaXEFile returns "The Path [...] has an unsupported file type of [System.IO.DirectoryInfo]." when receiving pipeline input from Get-DbaXESessionTargetFile
(Remark: but the problem is in Get-DbaXESessionTargetFile)
Steps to Reproduce
$SessionName = 'system_health'
$inst = Connect-DbaInstance -SqlInstance 'INSTANCENAME'
$xSess = Get-DbaXESession -SqlInstance $inst -Session $SessionName
$xsess | Get-DbaXESessionTarget | Get-DbaXESessionTargetFile | Read-DbaXEFilePlease confirm that you are running the most recent version of dbatools
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.7.1 dbatools {Select-DbaObject, Set-DbatoolsConfig, Add-DbaAgDatabase, Add-DbaAgListener…}
Script 2025.8.17 dbatools.library Get-DbatoolsLibraryPath
Other details or mentions
Some more details
$SessionName = 'system_health'
$inst = Connect-DbaInstance -SqlInstance 'INSTANCENAME'
$xSess = Get-DbaXESession -SqlInstance $inst -Session $SessionName
# works fine, returning 2 targets
$xsess | Get-DbaXESessionTarget
# DbaXESessionTargetFile fails
$xsess | Get-DbaXESessionTarget | Get-DbaXESessionTargetFile -Verbose
# returns
# VERBOSE: [13:11:49][Get-DbaXESessionTargetFile] Getting \\SERVERNAME\...\Log\system_health.xel
# VERBOSE: [13:11:49][Get-DbaXESessionTargetFile] Getting - followed by local Get-Childitem -recurse resultconsequently Read-DbaXEFile fails
$xsess | Get-DbaXESessionTarget | Get-DbaXESessionTargetFile | Read-DbaXEFile
# returns
#WARNING: [13:13:09][Read-DbaXEFile] The Path ...\somedir] has an unsupported file type of [System.IO.DirectoryInfo].On the other hand, Read-DbaXEFile itself works
$xsess | Read-DbaXEFile | select -first 1
#returned correct resultsRead-DbaXEFile works, because
- it uses a smart way to detect the input object
- filters correctly for targets having a file target (and skipping the ring buffer)
- replaces a '.xel' by '*.xel' to find all filesnames which could be created by this session
My idea was to use the similar logic for detecting and selecting the input object inside Get-DbaXESessionTargetFile.
A locally fixed version then worked (PR could follow if you want)
$xsess | Get-DbaXESessionTarget | Get-DbaXESessionTargetFile | Read-DbaXEFile What PowerShell host was used when producing this error
PowerShell Core (pwsh.exe), Windows PowerShell (powershell.exe)
PowerShell Host Version
5.1.20348.3932 local on server
7.4.11 when trying from remote (Win 11)
SQL Server Edition and Build number
Microsoft SQL Server 2022 (RTM-CU20-GDR) (KB5063814) - 16.0.4210.1 (X64) Jul 11 2025 13:04:02 Copyright (C) 2022 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2022 Standard 10.0 (Build 20348: ) (Hypervisor)
.NET Framework Version
PSChildName Version
----------- -------
Client 4.8.04161
Full 4.8.04161
Client 4.0.0.0