-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
DjArt
committed
Oct 14, 2019
1 parent
67c8b70
commit efc6a72
Showing
1 changed file
with
29 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
function Mount-VHD([string]$imagefile, [string]$dirname, [string]$tmpdir) | ||
function Mount-VHD([string]$imagefile, [string]$tmpdir, [string]$dirname = "") | ||
{ | ||
"select vdisk file=`"$imagefile`"" > "$tmpdir\Mount-VHD" | ||
"attach vdisk" >> "$tmpdir\Mount-VHD" | ||
"select partition 2" >> "$tmpdir\Mount-VHD" | ||
"assign mount=`"$dirname`"" >> "$tmpdir\Mount-VHD" | ||
(Get-Content -Encoding Unicode "$tmpdir\Mount-VHD" ) | Out-File -Encoding UTF8 "$tmpdir\Mount-VHD" | ||
Invoke-Expression "diskpart /s `"$tmpdir\Mount-VHD`"" | ||
Remove-Item "$tmpdir\Mount-VHD" | ||
"select vdisk file=`"$imagefile`"" > "$tmpdir\Mount-VHD" | ||
"attach vdisk" >> "$tmpdir\Mount-VHD" | ||
if ($dirname -eq "") | ||
{ | ||
|
||
} | ||
else | ||
{ | ||
"select partition 2" >> "$tmpdir\Mount-VHD" | ||
"assign mount=`"$dirname`"" >> "$tmpdir\Mount-VHD" | ||
} | ||
(Get-Content -Encoding Unicode "$tmpdir\Mount-VHD") | Out-File -Encoding UTF8 "$tmpdir\Mount-VHD" | ||
Invoke-Expression "diskpart /s `"$tmpdir\Mount-VHD`"" | ||
Remove-Item "$tmpdir\Mount-VHD" | ||
} | ||
|
||
function Unmount-VHD([string]$imagefile, [string]$dirname, [string]$tmpdir) | ||
{ | ||
"select vdisk file=`"$imagefile`"" > "$tmpdir\Unmount-VHD" | ||
"detach vdisk" >> "$tmpdir\Unmount-VHD" | ||
(Get-Content -Encoding Unicode "$tmpdir\Unmount-VHD" ) | Out-File -Encoding UTF8 "$tmpdir\Unmount-VHD" | ||
Invoke-Expression "diskpart /s `"$tmpdir\Unmount-VHD`"" | ||
Remove-Item "$tmpdir\Unmount-VHD" | ||
Remove-Item "$dirname" -Force | ||
"select vdisk file=`"$imagefile`"" > "$tmpdir\Unmount-VHD" | ||
"detach vdisk" >> "$tmpdir\Unmount-VHD" | ||
(Get-Content -Encoding Unicode "$tmpdir\Unmount-VHD") | Out-File -Encoding UTF8 "$tmpdir\Unmount-VHD" | ||
Invoke-Expression "diskpart /s `"$tmpdir\Unmount-VHD`"" | ||
Remove-Item "$tmpdir\Unmount-VHD" | ||
Remove-Item "$dirname" -Force | ||
} | ||
|
||
function Create-VHD([string]$imagefile, [string]$tmpdir, [string]$size) | ||
{ | ||
"create vdisk file=`"$imagefile`" maximum=$size type=expandable" > "$tmpdir\Create-VHD" | ||
(Get-Content -Encoding Unicode "$tmpdir\Create-VHD") | Out-File -Encoding UTF8 "$tmpdir\Create-VHD" | ||
Invoke-Expression "diskpart /s `"$tmpdir\Create-VHD`"" | ||
##Remove-Item "$tmpdir\Create-VHD" | ||
} |