powershell - Run "Invoke-Expression" statement as another user -


I have a PowerShell script / function, which takes some arguments and runs it.

  Invoke-Expression ". \ ScriptFile.ps1 $ ($ Node.Name) .xml C: \ TempFolder \ $ ($ Node.Name) Local"   

Another user now I want to run it

Inoc-expression does not have a built-in parameter credentials which gives this facility on the other hand in ash-command There is a credentials ( Get-Credential ) parameter which provides the facility to run as another user; invite-expression Tried to replace come-command .

How do I handle this given expression to run as a second user?

Script processing structure

  script deployment {SetScript = @ "Set-Location D: \ Invoke-Expression Apply". \ ScriptFile.ps1 $ ($ Node.Name) .xml C: \ TempFolder \ $ ($ node Knam) local "" Testskript = {return $ false} GetScript = {return @ {GetScript = $ GetScript SetScript = $ SetScript Testskript = $ TestScript}} DependsOn = "[File] CopyMe"}   

PS: This is all within a set script script user in desired state configuration

come-command actually on a local machine as a different user Can be used to run a script (as @majolinor said, this would be a separate session). You must have PowerShell Remoting enabled (which you almost do if you are using DSC) this command looks like this (assuming the translated version of your top voice):

  come-command-computer name - credential $ cred -file \ ScriptFile.ps1- Authorized list "$ ($ Node.Name) .xml", "C: \ TempFolder", $ node .name, "local"   

I suspect that this However your problems will not solve. The error message in your comment is just a common error, that means something went wrong. To get more clues, you need to help in troubleshooting.

Though what would be good, if you can tell us what you are trying to do eventually. What does it do. \ ScriptFile.ps1 Really ?

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -