Modules/Vhd/Pscx.Vhd.psm1
<#
#> function ScriptDiskPart($script) { $file = [io.path]::GetTempFileName() try { Set-Content $file $script -Encoding utf8 & diskpart /s $file > $null } finally { Remove-Item $file } } function EnsureFileExists($VHD) { if (-not (test-path $VHD -PathType leaf)) { throw "File $VHD not found." } } <# .SYNOPSIS Mounts a Virtual Hard Drive (VHD) file. .PARAMETER Path Path to the VHD file. #> function Mount-VHD { [CmdletBinding()] param ( [Parameter(Position=1, Mandatory=$true)] $Path ) EnsureFileExists $Path ScriptDiskPart @" select vdisk file="$Path" attach vdisk "@ } <# .SYNOPSIS Dismounts a Virtual Hard Drive (VHD) file. .PARAMETER Path Path to the VHD file. #> function Dismount-VHD { [CmdletBinding()] param ( [Parameter(Position=1, Mandatory=$true)] $Path ) EnsureFileExists $Path ScriptDiskPart @" select vdisk file="$Path" detach vdisk "@ } Export-ModuleMember Mount-VHD, Dismount-VHD # SIG # Begin signature block # MIIccgYJKoZIhvcNAQcCoIIcYzCCHF8CAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUWDlUWBjCp4UkAzEOhEx3TSgJ # 7QmgghehMIIFKjCCBBKgAwIBAgIQBLQS3h09OUqqdSKUe3ftPjANBgkqhkiG9w0B # AQsFADByMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYD # VQQLExB3d3cuZGlnaWNlcnQuY29tMTEwLwYDVQQDEyhEaWdpQ2VydCBTSEEyIEFz # c3VyZWQgSUQgQ29kZSBTaWduaW5nIENBMB4XDTE2MTAxMjAwMDAwMFoXDTE5MTAx # NzEyMDAwMFowZzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNPMRUwEwYDVQQHEwxG # b3J0IENvbGxpbnMxGTAXBgNVBAoTEDZMNiBTb2Z0d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X6Ybk7f+j6KIyX5F+Caz6xHKuDQhaAigOMO # EelTN/9g9NCOQy1grVfrsnS4wwag06zUxHlxaXiTVNM24pSmdVSvpkyvtVkVHL7b # YIwxFmcci8em95jatcwQyRCrXr8j1Y53I0oWu60kx4PkH/uhggIPMIICCwYJKoZI # hvcNAQkGMYIB/DCCAfgCAQEwdjBiMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGln # aUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhE # aWdpQ2VydCBBc3N1cmVkIElEIENBLTECEAMBmgI6/1ixa9bV6uYX8GYwCQYFKw4D # AhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8X # DTE3MTAxMzAzMDEzN1owIwYJKoZIhvcNAQkEMRYEFDioxTRWVHJp/kA6ztSua35k # gMWzMA0GCSqGSIb3DQEBAQUABIIBABITqh+3LM/liCtzGxKBwUt+MwLEs2NKThtq # 2hGurWPXbvI+yIwYbTQOEcEfxx9FTETbbHpu0jY3dNjKQ93+KhrjRktl/zaaqh4a # DsIjClhkpLPBZA14tNZpkiD2FsCEeA3D3IqUmiOozNgNU516KOFLXr9PHmKu92Xx # i1lPyFnxDp+gWwNEQWXPbN4mlugG3mNq4PaPBA7uNrYIubP2PxHNY2mewQ7EQJk2 # jJaWpcH6yNw6nSf77cPKXmPARrmBKYEKqfRWvmwuamlQOEFEPJvtVWXd4UqUgt7J # UiqD1M6tSf6IR+fk+MD4kwNtKKSNNArRgR9Cvmxgv0FlqF35sEA= # SIG # End signature block |