With PowerShell comes the ability to map drives to PSProviders through the command New-PSDrive. Some of the native PSProviders are FileSystem and Registry.
The New-PSDrive command also allows you to provide credentials (for example other than the one you are using to execute the script.
Now here comes the gotcha… Although the New-PSDrive command supports the -Credential parameter, the native PSProviders do not. Now what does that mean?
When you use the New-PSDrive command to, for example, create a drive mapping to a file share, let’s say to share on an AS400 system where you would need to use other credentials than the current logged on user, the mapping will fail stating that the parameter is not supported with the PSProvider. So, although the New-PSDrive supports the –Credential parameter the FileSystem PSProvider does not.
In the case of a mapping to a file share, an alternative for this is to use the good old net use for creating the mapping.
Microsoft has recognized this issue, but when you don’t know about this limitation it can cause some serious headache when you’re scripting. With this reason I wrote this post… just to make you aware of this issue.