-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Open
Labels
WG-Interactive-Consolethe console experiencethe console experienceWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation
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
WG-Interactive-Consolethe console experiencethe console experienceWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation

