Change default behavior of module import
Votes from Connect: 15
Original Date Submitted: 3/31/2010 2:02:45 PM
Handle: Martin Zugec
Site Name: PowerShell
Feedback ID: 546066
Frequency: Always Happens
Regression: Yes, this happens in previous beta versions
Please re-consider default behavior of Import-Module. Current issue is that if you want to use namespaces (module\verb-noun), you still need to pay attention to name of your functions, because last one always wins.
This forces us to use SCCM\Get-SccmObject always simply because of the fact that we never know which function we will overwrite. SCCM\Get-Object would overwrite Get-Object in this case. This makes modules less useful.
Default behavior should be that current functions are not overwriten - if there is conflict, new functions should be available by Namespace only.
Product Studio item created by Connect Synchronizer due to creation of feedback ID 546066 (http://connect.microsoft.com/PowerShell/feedback/ViewFeedback.aspx?FeedbackID=546066).
1.) Create module SCCM.psm1
2.) Create function Get-Object and export it from module
3.) You can access this function using SCCM\Get-Object (perfect), however it will overwrite built-in Get-Object
I would expect that new functions won't overwrite existing ones. From design perspective, modules can be easily used as dynamic libraries of functions - but if they are not loaded all at once, it can be extremely dangerous, because you never know what you will overwrite.
Internal BugId: 2493