Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix for #2442 - automounted drives in modules#3034

Merged
lzybkr merged 6 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
anmenaga:AutomountedDrivesFixanmenaga/PowerShell:AutomountedDrivesFixCopy head branch name to clipboard
Mar 7, 2017
Merged

Fix for #2442 - automounted drives in modules#3034
lzybkr merged 6 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
anmenaga:AutomountedDrivesFixanmenaga/PowerShell:AutomountedDrivesFixCopy head branch name to clipboard

Conversation

@anmenaga

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.