Repository navigation
Open
Labels
Review - MaintainerThe PR/issue needs a review from the PowerShell repo Maintainers
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Usually when I use a backgrounded Write-Host I call it this way:
Write-Host "text" -BackgroundColor DarkBlue -NoNewline
and then I add a Write-Host "`n"
in order to make it fit the string and the string ONLY
in certain contextes though when there is a Remove-Item around the trick doesn't work anymore
Reproducible example:
# Vars
$edge_appdata_path = "$($env:LOCALAPPDATA)\Microsoft\Edge\User Data"
$edge_backup_path = "$($env:USERPROFILE)\Desktop\test\User Data.7z"
$edge_files_to_backup = @("Default\Preferences","Default\Bookmarks","Default\Bookmarks.bak","Default\Extensions","Default\Secure Preferences","Default\IndexedDB","Local State")
$temp_backup_dir = "$env:TEMP\EdgeBackupTemp"
Write-Host "TEST" -ForegroundColor White -BackgroundColor DarkBlue -NoNewline
Write-Host "`n"
# Create fake
New-Item -Path $edge_backup_path -Force | Out-Null
# Create .Bak file
Copy-Item -LiteralPath $edge_backup_path -Destination "$($edge_backup_path).bak" -Force
Remove-Item -LiteralPath $edge_backup_path -Force
# Create structure
New-Item -ItemType Directory -Path "$temp_backup_dir\User Data" | Out-Null
New-Item -ItemType Directory -Path "$temp_backup_dir\User Data\Default" | Out-Null
# Copy
foreach ($file in $edge_files_to_backup) {
$temp_source_path = Join-Path -Path $edge_appdata_path -ChildPath $file
$temp_dest_path = Join-Path -Path $temp_backup_dir -ChildPath "User Data\$file"
if (Test-Path $temp_source_path) {
Copy-Item -Path $temp_source_path -Destination $temp_dest_path -Recurse -Force
}
}
# Desktop archive
Write-Host "archiving edge files" -ForegroundColor Black -BackgroundColor DarkGray -NoNewline
Write-Host "`n"
& 7za a $edge_backup_path "$temp_backup_dir\User Data\*" -t7z -m0=lzma2 -mx7
# Cleanup temp files
Remove-Item -Path $temp_backup_dir -Recurse -Force #TRY TO COMMENT THIS LINE OUT (it should fix it)
Write-Host "`n`n`n`n"
Write-Host "TEST" -ForegroundColor White -BackgroundColor DarkBlue -NoNewline
Write-Host "`n"
For 7za : https://www.7-zip.org/download.html
Expected behavior
Actual behavior
Error details
Environment data
Name Value
---- -----
PSVersion 7.5.1
PSEdition Core
GitCommitId 7.5.1
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No response
Metadata
Metadata
Assignees
Labels
Review - MaintainerThe PR/issue needs a review from the PowerShell repo Maintainers


Activity
mklement0 commentedon Jun 21, 2025
pier124 commentedon Jun 21, 2025
Done, you'll need edge and 7za (console version of 7z) to reproduce it
237dmitry commentedon Jun 21, 2025
I could not reproduce:
pier124 commentedon Jun 22, 2025
OS: Windows 11
PS: commenting this line out: #Remove-Item -Path $temp_backup_dir -Recurse -Force (line 37) does fix it
pier124 commentedon Jun 23, 2025
I tested it via 7.6.0-preview.4 and it works (thanks 237dmitry )
kilasuit commentedon Jul 24, 2025
Investigation
I dug into this & whilst trying to build a smaller reproducabile example as I didn't think this really required 7za to repro. I noticed pier124 rasied this with an older version of 7za (v24.09) vs the latest release (v25.00) & with the newer release, initially I wasn't able to replicate this in 7.5.1 both with & without 7za. This was both in a Windows Sandbox on
Microsoft Windows 10.0.19041(which is Win10 22h2) & directly on the host for that sandbox.I Did start to think that this may then be caused by the 7za program, vs it being a PowerShell Issue, however remembered that we've had a fix to how Progress bar works which also impacts Cmdlets like Remove-Item etc, which off top of my head I do believe this update is only in the preview versions & need to chase down the PR that changed this & will test prior previews shortly.
pier124 - I'd recommend also updating 7za anyway.
pier124 commentedon Jul 25, 2025
Ryan Yates (@kilasuit)

Still works properly on 7.6.0-preview.4 though
kilasuit commentedon Jul 25, 2025
This was added in 7.6.0-preview.1 (hence it working in 7.6.0-preview.4) as part of the following PR #24013 & has not yet been marked for backporting to the 7.5.x releases.
I'm not gonna spend more time on this, however, I also am wondering if this could crop up again even with #24013 having been merged depending on whether or not this goes beyond the 2 seconds limit that was added in that PR however I've not managed to get a consistent reproducible example that doesn't require either 7za or Edge so it's a really bad example here. I also dont really think that 7za is actually apart of this issue & think it is bleed to the host from how the ProgressBar gets drawn, as I sorta remember this being mentioned in previous issues.
theJasonHelmick commentedon Aug 20, 2025
Thank you Ryan Yates (@kilasuit) for do this work. pier124, can you re-test to validate this is now working?
pier124 commentedon Aug 24, 2025
Jason Helmick (@theJasonHelmick) How do I test it? Where do I grab the updated release?
kilasuit commentedon Aug 25, 2025
pier124 - as I mentioned above this hasn't yet been marked for a 7.5.x release and is only in the 7.6.0-previews.
It may come in 7.5.3 or a later release.
microsoft-github-policy-service commentedon Feb 22, 2026
This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.
Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.
kilasuit commentedon Feb 22, 2026
The PR that fixed this still needs backporting to the 7.5 release branch.