From 3d0b877ff7485018a61c9d4a5ad6df7854057d7d Mon Sep 17 00:00:00 2001 From: 0x7FFFFFFFFFFFFFFF <39968+0x7FFFFFFFFFFFFFFF@users.noreply.github.com> Date: Wed, 24 Jan 2024 11:55:30 -0800 Subject: [PATCH] Update Get-DbaFile.ps1 (#9202) --- public/Get-DbaFile.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/Get-DbaFile.ps1 b/public/Get-DbaFile.ps1 index 3d8d87ebb5..e26a986d7f 100644 --- a/public/Get-DbaFile.ps1 +++ b/public/Get-DbaFile.ps1 @@ -191,7 +191,14 @@ function Get-DbaFile { foreach ($type in $FileTypeComparison) { if ($row.filename.ToLowerInvariant().EndsWith(".$type")) { $fullpath = $row.fullpath.Replace("\", $separator) + + # Replacing all instances of '\\' with single backslashes '\', and maintain the leading SMB share path represented by the initial '\\'. + $is_smb_share_path = $fullpath.SubString(0, 2) -eq "\\" $fullpath = $fullpath.Replace("\\", "\") + if ($is_smb_share_path) { + $fullpath = $fullpath -replace "^\\", "\\" + } + $fullpath = $fullpath.Replace("//", "/") [PSCustomObject]@{ ComputerName = $server.ComputerName @@ -220,4 +227,4 @@ function Get-DbaFile { } } } -} \ No newline at end of file +}