Skip to content

Commit

Permalink
[common.vm] Remove PS_Transcripts in VM-Clean-Up
Browse files Browse the repository at this point in the history
Remove as much of `PS_Transcripts` as possible in
`VM-Remove-DesktopFiles` (called by `VM-Clean-Up`).
  • Loading branch information
Ana06 committed Jan 4, 2024
1 parent bc5f376 commit c0c84d4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/common.vm/tools/vm.common/vm.common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,19 @@ public class Shell {
}
}

# Remove a directory and if not possible as many of its subfolder and files as possible
function VM-Remove-Dir {
param (
[Parameter(Mandatory=$true)]
[string[]]$item
)
Remove-Item -Path $item -Recurse -Force -ErrorAction Continue
if (!$? -and $item.PSIsContainer) {
Get-ChildItem -Path $item -Force | ForEach-Object {
VM-Remove-Dir $item
}
}
}

# Usage example:
# VM-Remove-DesktopFiles -excludeFolders "PS_Transcripts", ${Env:TOOL_LIST_DIR}, "fakenet_logs" -excludeFiles "example.txt", "important.doc"
Expand Down Expand Up @@ -1284,6 +1297,9 @@ function VM-Remove-DesktopFiles {
}
}
}

# Remove as much of PS_Transcripts as possible
VM-Remove-Dir "PS_Transcripts"
}

function VM-Clear-TempAndCache {
Expand Down

0 comments on commit c0c84d4

Please sign in to comment.