Skip to content

Conversation

@anmenaga
Copy link

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:
afterfix_onhypervmachine
Test results on Non-Hyper-V machine after fix:
afterfix_onsimplevm

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

@PowerShellTeam PowerShellTeam added the Review - Needed The PR is being reviewed label Jan 24, 2017
{
result = AutomountFileSystemDrive(name);
// first try to automount as a file system drive
result = AutomountFileSystemDrive(name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Files should end with a newline.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}
Dismount-VHD $VHDPath
Remove-Item $VHDPath
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Files should end with a newline.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

& $powershell -noprofile -command "$AutomountVHDDriveScriptPath -useModule -VHDPath $vhdPath" | Should Be "Drive found"
}
}
} No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Files should end with a newline.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Context "Validating automounting FileSystem drives" {

It "Test automounting using subst.exe" -Skip:$SubstNotFound {
& $powershell -noprofile -command "$AutomountSubstDriveScriptPath -FullPath $substDir" | Should Be "Drive found"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated; Thank you.

@lzybkr lzybkr merged commit 1d1cffd into PowerShell:master Mar 7, 2017
@iSazonov iSazonov removed the Review - Needed The PR is being reviewed label Mar 27, 2017
@anmenaga anmenaga deleted the AutomountedDrivesFix branch October 31, 2018 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When a volume is mounted after a module is loaded, that volume is not visible from the module code

4 participants