Fix for #2442 - automounted drives in modules#3034
Conversation
There was a problem hiding this comment.
The old code only created file system drives if the current scope was global.
Will your change create the drive in global scope or module scope?
Personally, I would expect the drive to be in global scope.
I would also like to see tests to cover that scenario either way.
There was a problem hiding this comment.
After this change, new drives will be created in global scope; I've added a check for this to tests.
| { | ||
| Remove-Module $m | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Files should end with a newline.
| } | ||
| Dismount-VHD $VHDPath | ||
| Remove-Item $VHDPath | ||
| } No newline at end of file |
There was a problem hiding this comment.
Files should end with a newline.
| & $powershell -noprofile -command "$AutomountVHDDriveScriptPath -useModule -VHDPath $vhdPath" | Should Be "Drive found" | ||
| } | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Files should end with a newline.
There was a problem hiding this comment.
This could fail in a couple ways if there are spaces in the path, a fix would look something like this:
You can use:
& $powershell -noprofile -command "& '$AutomountSubstDriveScriptPath' -FullPath '$substDir'" | Should Be "Drive found"
This fixes #2442
Added tests using: 1) 'subst.exe' utility 2) New-VHD/Mount-VHD cmdlets .
Also added tests that verify automounted drives without modules in the picture to use as baseline.
Test results on Hyper-V machine after fix:


Test results on Non-Hyper-V machine after fix:
For reference - test results on Hyper-V machine before fix:


For reference - test results on Non-Hyper-V machine before fix: