Skip to content

Conversation

@potatoqualitee
Copy link
Member

Fixes #9840

Changes

  • Remove -Recurse parameter that was causing Get-ChildItem to return DirectoryInfo objects instead of FileInfo objects
  • Add support for Microsoft.SqlServer.Management.XEvent.Session objects as input (like Read-DbaXEFile)
  • Change InputObject parameter type from Target[] to object[] to accept both Session and Target objects
  • Add logic to replace .xel with *.xel to find all related session files
  • Apply dbatools style guidelines: use splat for 3+ parameters
  • Improve error handling with proper target information

Testing

This fix enables both pipeline scenarios:

# Original reported issue - now works
$xsess | Get-DbaXESessionTarget | Get-DbaXESessionTargetFile | Read-DbaXEFile

# Simpler direct pipeline - also works
$xsess | Get-DbaXESessionTargetFile | Read-DbaXEFile

Generated with Claude Code

…ession object support

Fixes #9840

- Remove -Recurse parameter that was causing Get-ChildItem to return DirectoryInfo objects instead of FileInfo objects
- Add support for Microsoft.SqlServer.Management.XEvent.Session objects as input (like Read-DbaXEFile)
- Change InputObject parameter type from Target[] to object[] to accept both Session and Target objects
- Add logic to replace .xel with *.xel to find all related session files
- Apply dbatools style guidelines: use splat for 3+ parameters
- Improve error handling with proper target information

Co-authored-by: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
@potatoqualitee
Copy link
Member Author

@claude cant you just do -File and not remove? also pls add regression test IF this has any integration tests, which it might not bc of appveyor vs unc

@claude
Copy link

claude bot commented Nov 4, 2025

Claude finished @potatoqualitee's task —— View job


Completed requested changes

  • Read current implementation of Get-DbaXESessionTargetFile.ps1
  • Check if integration tests exist for this command
  • Use -File parameter instead of removing -Recurse from Get-ChildItem
  • Add regression test (only unit tests exist, no integration tests per AppVeyor/UNC concern)
  • Commit and push changes

Changes made

Modified public/Get-DbaXESessionTargetFile.ps1:

  • Added -File parameter to all three Get-ChildItem calls (lines 100, 110, 114)
  • This explicitly filters for files only, preventing DirectoryInfo objects from being returned
  • Cleaner approach than removing -Recurse as it's more explicit about intent

Modified tests/Get-DbaXESessionTargetFile.Tests.ps1:

The -File parameter is a better solution because it clearly communicates that only file system files should be returned, which directly addresses the issue where DirectoryInfo objects were being returned instead of FileInfo objects.


| Branch

…-Recurse and add regression test

- Add -File parameter to Get-ChildItem calls to ensure only FileInfo objects are returned
- Add regression test to verify InputObject accepts Session objects (issue #9840)
- This approach is cleaner than removing -Recurse as it explicitly filters for files

Co-authored-by: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

Get-DbaXESessionTargetFile returns invalid [System.IO.DirectoryInfo]

1 participant