Running 64-bit Windows PowerShell from Orchestrator

Running 64-bit Windows PowerShell from Orchestrator

Q: How can I run 64-bit PowerShell commands from System Center Orchestrator on the runbook server?

A: Because System Center Orchestrator is actually 32-bit code (even SP1) it isn't possible to run 64-bit Windows PowerShell from a normal command execution. However, it's still possible with a little piece of script.

  1. Create a Run .Net Script activity from the System activities group.
  2. Select PowerShell as the language.
  3. In the Script area enclose your PowerShell commands in the following code:

    Invoke-Command -ScriptBlock {YOUR CODE} -ComputerName localhost
    

     
  4. Click Finish

The only requirement is that WinRM must be enabled on the runbook server, which can be accomplished very easily by running the "winrm quickconfig" command. It's enabled by default on Windows Server 2012.

A more powerful option that allows the passing of credentials is shown below:

$Username = "domain\username"
$Password = "Password"
$ServerName = "hostname"
$ErrorActionPreference = "Stop"

try
{
    $securePassword = ConvertTo-SecureString $Password -AsPlainText -Force
    $credential = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $Username,$securePassword
    Invoke-Command -ComputerName $ServerName -credential $credential -ScriptBlock {YOUR CODE}
}
catch
{
Throw $_.Exception
}

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish