-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Milestone
Description
Steps to reproduce
param($VHDPath = "${env:TEMP}\test.vhd")
function CreateVHD ($VHDPath, $Size)
{
$drive = (New-VHD -path $vhdpath -SizeBytes $size -Dynamic | `
Mount-VHD -Passthru | `
get-disk -number {$_.DiskNumber} | `
Initialize-Disk -PartitionStyle MBR -PassThru | `
New-Partition -UseMaximumSize -AssignDriveLetter:$False -MbrType IFS | `
Format-Volume -Confirm:$false -FileSystem NTFS -force | `
get-partition | `
Add-PartitionAccessPath -AssignDriveLetter -PassThru | `
get-volume).DriveLetter
$drive
}
$m = New-Module {
function Test-DrivePresence
{
param ([String]$Path)
Write-Output "Testing path: $Path"
if (Test-Path $Path)
{
Write-Output "Exists"
}
else
{
Write-Output "Does not exist"
}
Write-Output "Running Get-PSDrive"
Get-PSDrive | Out-Host
Write-Output "Testing path: $Path"
if (Test-Path $Path)
{
Write-Output "Exists"
}
else
{
Write-Output "Does not exist"
}
}
Export-ModuleMember -Function Test-DrivePresence
}
Write-Output "Precondition: start from fresh PS session, do not have the media mounted"
try
{
ipmo $m
$drive = CreateVHD -VHDPath $VHDPath -Size 25mb
Test-DrivePresence -Path "${drive}:"
}
finally
{
Remove-Module $m
Dismount-VHD $VHDPath
del $VHDPath
}
Thanks goes to @lzybkr for making this repro script.
Expected behavior
- Load a module
- Mount a VHD
- VHD should be visible from the context of the module, without needing to run Get-PSDrive (e.g. when doing parameter validation using ValidateScript)
Actual behavior
- Load a module
- Mount a VHD
- The mounted volume is not visible, until Get-PSDrive is invoked. This is very non-intuitive.
Environment data
PS D:\temp\aaa.ps1> $psversiontable
Name Value
---- -----
PSVersion 5.1.14393.187
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.187
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime