Run whole script with different credentials

This topic contains 5 replies, has 2 voices, and was last updated by  kishor 5 months ago.

  • Author
    Posts
  • #73172

    kishor
    Participant

    Hi Team,
    I am having a script which maps drives for robocopy and then does changes on a group of files on the destination folder. How do I run this whole script with different credentials depending on the domain. I tried creating a hashtable with diff credentials and then running the script inside invoke-command using credentials parameter but I get below error;
    Cannot process argument transformation on parameter 'Credential'. Cannot invoke this function because the current host does not implement it.

    Regards,
    Kishor

  • #73181

    Don Jones
    Keymaster

    Well, without seeing your code, or at least some of it, it's impossible to tell you what the error is referring to.

    However, "to run an entire script under different credentials" you would use Start-Process or Invoke-Command. But you can't provide a hash table of credentials to either of those; you need to flat-out provide a credential. You'll probably have to write a "wrapper" script that makes the decision on which credential to use.

    • #73192

      kishor
      Participant

      Hi Don,
      Thanks for your time, below is the link for the script;

      Regards,
      Kishor

    • #73195

      kishor
      Participant

      Another thing to mention is I am running this script in a 'Run .Net' SCO activity which is failing with this error.

      Thanks,
      Kishor

  • #73238

    Don Jones
    Keymaster

    You would need, then, to have SCO running the script under alternate credentials. There's not a way to assert a new identity within the script itself.

    • #73298

      kishor
      Participant

      Thank you Don!

You must be logged in to reply to this topic.