locked
Powershell error when running script RRS feed

  • Question

  • Im trying to setup a task using a powershell script to change the terminalservicesprofilepath in Scorch.  I have the following code:

    $tspath = "\\test\path"
    $userDN = [ADSI]"LDAP://CN=lab test,OU=lab,DC=test,DC=com"
    $userDN.psbase.InvokeSet("Terminalservicesprofilepath",$tspath)
    $userDN.psbase.CommitChanges()

    It works 100% when I open a powershell console on the runbook server.  However, if I put the exact same code in a blank runbook, I get an error:

    Exception calling "InvokeSet" with "2" argument(s): "Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))"

    I have tried running it as

    $userDN.psbase.InvokeSet("Terminalservicesprofilepath","\\test\path")

    But it gives me the exact same error.  I have scoured the internet without any luck (besides finding other people with the same issue).  Anyone have any insights?  Thanks.

    Friday, May 3, 2013 6:47 PM

Answers

  • Hello,

    I tried your script. It works after adding the service account to Domain Admin group AND restarting the "Orchestrator Runbook Service".

    Before adding the service account to Domain Admin group AND restarting the "Orchestrator Runbook Service" I got an error diffrent from yours:

    Regards

    Stefan


    www.sc-orchestrator.eu , Blog sc-orchestrator.eu

    • Proposed as answer by Bart Timmermans- Monday, May 6, 2013 12:03 PM
    • Marked as answer by BrewNinja Monday, May 6, 2013 1:25 PM
    Saturday, May 4, 2013 8:04 PM
    Answerer

All replies

  • Hi,

    does the account running "Orchestrator Runbook Service" have sufficient permission in the AD to perform this?

    Does the script run on PowerShell when you logged on with the account running "Orchestrator Runbook Service"?

    Regards,

    Stefan


    www.sc-orchestrator.eu , Blog sc-orchestrator.eu

    Friday, May 3, 2013 7:42 PM
    Answerer
  • I assigned the service account full control over AD for testing (as well as made it a domain admin).  When I run a powershell console as the service account user, it runs just fine.  I should mention probably that the runbook server is Server 2012.  I also tried running it with $pse = Powershell {(commands)} to make sure it wasnt a powershell 2 vs 3 issue, but that didnt help either (also launched a powershell 2.0 console as the service account and it ran fine).  It just wont run inside orchestrator.
    Friday, May 3, 2013 8:24 PM
  • Hello,

    I tried your script. It works after adding the service account to Domain Admin group AND restarting the "Orchestrator Runbook Service".

    Before adding the service account to Domain Admin group AND restarting the "Orchestrator Runbook Service" I got an error diffrent from yours:

    Regards

    Stefan


    www.sc-orchestrator.eu , Blog sc-orchestrator.eu

    • Proposed as answer by Bart Timmermans- Monday, May 6, 2013 12:03 PM
    • Marked as answer by BrewNinja Monday, May 6, 2013 1:25 PM
    Saturday, May 4, 2013 8:04 PM
    Answerer
  • That indeed did the trick!  Never would have thought of that.  Thanks for saving my sanity!
    Monday, May 6, 2013 1:25 PM