OK, time for another PowerShell v2 feature request: we need namespaces.
Right now, if we call AD cmdlets getting user objects Get-User and this snapin gets installed on the box which already has Exchange 2007 management tools which also have Get-User - my scripts stop working.
What I would like to have (please) is some kind of using construct which would make the snapin name I supply default for subsequent name resolution. And of course at any time I should be able to use the full name to disambiguate. This is the PowerShell code I would like to supply in v2 era:
#the statement below makes the specified snapin default for name resolution
using Quest.ActiveRoles.ADManagement
Get-User "Dmitry Sotnikov" | Set-User -city “St. Petersburg” #AD snapin is used
new-group qdl.powershell #AD snapin used
#the command below is explicitly using Exchange 2007 new-mailbox
Microsoft.Exchange.Management.PowerShell.Admin\new-mailbox conf234 | ForEach-Object {
#This is using AD again
set-user –Description “Created by Exchange”
}
This will remove the necessity to prefix each noun (which Kirk opposes and for a good reason), and does not require everyone to create custom namespace management functions (like Antonio is doing) which don’t work for all scenarios and are not present on each workstation out there anyway so the scripts you publish in the internet don’t necessarily work, people have to copy-paste 2-line function just to run your one-liner, etc.
I think this kind of namespace support is something PowerShell team absolutely needs to provide in v2 or things will start getting really confusing very soon: even just at Microsoft how many products have some kind of notion of users, sites, computers, etc. We are on a collision course here.
I’ve submitted this to Microsoft Connect: https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=301052&SiteID=99 - feel free to vote for the CR over there.
Tags: Blogosphere, KB, Knowledge Base, Known Issues, PowerShell
Subscribe by email






Hi Dmitry,
Don’t forget to vote for your own suggestion on Microsoft Connect by giving it 5 stars!
Kirk out.
http://poshoholic.com
Will they know it’s me?
I honestly don’t know. I just noticed that I could give myself a star rating once per post, so naturally my posts always start out with a 5 star rating! h)
I’m receiving Page Not Found when following the link to Microsoft Connect (after logging in with my Live Passport account):
Page Not Found
The content that you requested cannot be found or you do not have permission to view it.
If you believe you have reached this page in error, click the Contact Us link at the bottom of the page to report the issue and include this ID in your e-mail: 91210b01-d538-477f-9851-f86580d017b3
Microsoft Connect welcome page.
Please try again: I’ve just followed the link and could get to the page with no problem.
It did make me log in though so I am guessing that it might have not let you in because you were not on the PowerShell program (tough new rules so Kirk can no longer cheat on his CRs? ;))
Could you go to My Participation and ensure that Windows PowerShell is in the list?
If it is not, please go to Available Connections and sign-up for PowerShell.
Once you get onto the PowerShell program please try again to go and vote for the CR. The more votes we get the bigger are the chances to get this one through.
Cheat on my CRs? I’m not cheating. I’m just positively reinforcing the need to fix the issues…
Hi
Actually, I’m against the idea of using namespaces - I think the right direction is to use a provider. In this way, only a very few cmdlets needs to exists and this would speed up user’s work. Why should I have a Get-Mailbox when I already know how to get an object with Get-Item - just give me a location of e.g. Exchange:\Mailboxes.