PowerShell and untrusted domains

I have a few PowerShell scripts that execute various automation tasks on our build machine, like sanity test of the latest build for example. The common scenario is to revert-VMWare-snapshot, copy latest build to target machine, execute whatever needs to be executed. This worked fine until I was asked to do the same tests on different domain, which is not in trust with domain of our build machine.

At first glance, I thought that –Credentials parameter in PowerShell will do the trick, but it turned out it doesn’t work at all for functions like Copy-Item or Set-Content. I thought “ok, let’s check PowerShell 2, I’m sure it is implemented now”. To my surprise, I still get the same error “The provider does not support the use of credentials”. So I was stuck…

At some moment, I have remembered there was a command that allowed storing credentials for network connections. After a short search, I have found it and it indeed worked! The command I’m talking about is “net use”. The usage is very easy as well:

net use \\server\share /user:domain\username password

Any PowerShell command I needed (copy, delete, set content, etc.) worked fine after this call.

Technorati Tags: ,

posted @ Thursday, December 03, 2009 11:25 AM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
Please add 1 and 3 and type the answer here:
 

Live Comment Preview: