One of the things we love about the Windows PowerShell community is that folks are not shy. It turns out that having a vocal community is a great way to build and evangelize a product like ours. Of course, the Unix guys had this all figured out a long time ago.
Positive comments are good and all, but it’s difficult to really improve without being told where we came short. One of the ways we take feedback from the community for Windows PowerShell is through our public Microsoft Connect site. On that site anyone with a Live ID can log a bug or suggestion against Windows PowerShell. Items then get voted up or down by the community according to popularity.
We don’t get to implement every suggestion and fix every bug, but it’s a great way for us to understand what people are looking for and how important it is to them. With Windows PowerShell 3.0 we fixed over 200 items that were filed on Connect. This post will quickly touch on a few improvements to the FileSystem Provider based on this community feedback.
Support for Credentials
PowerShell MVP Joel Bennett filed a suggestion a few years ago asking that we support credentials with the FileSystem Provider. That suggestion was recently our 4th most voted item with 82 votes. The scenario is quite basic: You want to access a network file share, and that share requires a different set of credentials than the ones you are currently logged on with.
I’m happy to say that support for credentials on the FileSystem provider is available in Windows PowerShell 3.0! To use alternate credentials, simply use the Credential parameter on the New-PSDrive cmdlet
PS > New-PSDrive -Name J -PSProvider FileSystem -Root \\server001\sharename -Credential mydomain\travisj
Name Used (GB) Free (GB) Provider Root
---- --------- --------- -------- ----
J FileSystem \\server001\sharename
You can use all of the regular provider cmdlets like Get-ChildItem, Set-Location and Copy-Item against this new PSDrive just as you would normally – no need to specify the credentials over and over.
It gets better! By specifying the Persist switch parameter to the New-PSDrive cmdlet, the PSDrive will stay mounted across sessions. That line would look like:
PS > New-PSDrive -Name J -PSProvider FileSystem -Root \\server001\sharename -Credential mydomain\travisj -Persist
Moving items across drives
While we’re on the subject of the provider cmdlets, I want to mention that Move-Item can now move items across PSDrives. Using the PSDrive created above, we can move items from the network share (that was even mounted using a different set of credentials) to a location on the local file system. This one-liner will copy all XML files from the network share to a temporary directory on my computer.
Move-Item -Path J:\*.xml -Destination C:\temp
Finally, we know that users have experienced difficulty working with files that contain characters like ‘[‘ or ‘]’. To help with this in Windows PowerShell 2.0, we added the LiteralPath parameter to some of the provider cmdlets. With Windows PowerShell 3.0, we have now added
LiteralPath to the Rename-Item cmdlet (the last of the provider cmdlets) and in many other places. LiteralPath is now available on 49 different cmdlets in Windows PowerShell 3.0!
Now that you’ve read this post, head on over to our Connect site and file a suggestion or bug for us. Or vote someone else’s up.
Travis Jones [MSFT]
Program Manager - Windows PowerShell