Skip to content

Commit

Permalink
Need to get children folder in the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
taliesins committed Jan 14, 2024
1 parent 2b86fe1 commit 1a94deb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions api/hyperv-winrm/vhd.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ function Expand-Downloads {
)
process {
Push-Location $FolderPath
$vhdPath = Get-ChildItem $tempPath *"Virtual Hard Disks"* -Recurse -Directory
get-item *.zip | % {
$tempPath = join-path $FolderPath "temp"
Expand All @@ -98,6 +97,8 @@ function Expand-Downloads {
[System.IO.Compression.ZipFile]::ExtractToDirectory($_.FullName, $tempPath)
}
$vhdPath = Get-ChildItem $tempPath *"Virtual Hard Disks"* -Recurse -Directory
if (Test-Path $($vhdPath.FullName)) {
Move-Item "$($vhdPath.FullName)\*.*" $FolderPath
} else {
Expand All @@ -117,7 +118,9 @@ function Expand-Downloads {
$command = """$7zPath"" x ""$($_.FullName)"" -o""$tempPath"""
& cmd.exe /C $command
if (Test-Path $($vhdPath.FullName)) {
$vhdPath = Get-ChildItem $tempPath *"Virtual Hard Disks"* -Recurse -Directory
if ($vhdPath -and Test-Path $($vhdPath.FullName)) {
Move-Item "$($vhdPath.FullName)\*.*" $FolderPath
} else {
Move-Item "$tempPath\*.*" $FolderPath
Expand All @@ -140,7 +143,9 @@ function Expand-Downloads {
$command = """$tarPath"" -C ""$tempPath"" -x -f ""$($_.FullName)"""
& cmd.exe /C $command
if (Test-Path $($vhdPath.FullName)) {
$vhdPath = Get-ChildItem $tempPath *"Virtual Hard Disks"* -Recurse -Directory
if ($vhdPath -and Test-Path $($vhdPath.FullName)) {
Move-Item "$($vhdPath.FullName)\*.*" $FolderPath
} else {
Move-Item "$tempPath\*.*" $FolderPath
Expand Down

0 comments on commit 1a94deb

Please sign in to comment.