Orchestrator Integration Pack for PowerShell Script Execution 1.2

This Integration Pack provides extended PowerShell Script Execution capabilities for the Orchestrator (executed from and against both x86 and x64 OSs). For more information, please refer to its related Building Clouds (http://aka.ms/BuildingClouds) blog post.

 
 
 
 
 
4.9 Star
(14)
10,451 times
Add to favorites
System Center
10/1/2013
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • A few thoughts on the IP
    5 Posts | Last post November 22, 2018
    • Really nice work! An awesome OIP that rocks over the included Run .NET Script.  However, it has some room to really shine.
      
      1) Activity Published data - Can't believe this was left out.  I do see the replacement of publishing the results replacing that feature.  However that comes with some extra work.  Interestingly enough, when I have multiple values in this, the databus does not see it as an array though it shows that way in the Runbook Tester results view.
      
      2) Logging Published data - This is painful.  Not being able to look at the log and see what the execution published data was makes debugging a serious hassle.  I didn't know this could be done?  Isn't the "Published Data" the same for the log and the activity?
      
      I do appreciate the work done here!  Adding these two missing features would make this IP an absolute essential part of any Orchestrator 2012 installation.
      
      What about making this an open source project?
    • Then you have the ah ha! Moment.  One caveat for readers, if you DO NOT have Write-Host commands, then only use the Results XX published data property not Results XX (with Write-Host).  The latter will be empty.  My initial thought was that this property was cumulative, so if you didn't have Write-Host it would have just the results, not so.  
      
      After research, custom activity published data is only available for scratch built IPs that do not use the OIK.  Still wondering on the logging of published data.
    • After thrashing with this for a few days I found the root cause.  First off, I love this IP!
      
      What was killing me and giving me really strange behavior was that I was invoking a runbook which in that invoked runbook would execute a DB query which was in turn linked to the return data activity.  In the activity, the parameters each parameter value had a [Field()] with the "Full line as a string, fields separated by ;" published value which was parsed according to position (1,2,3, etc.).  Problem was when the query returned zero rows (which was possible), the runbook would return that as a success, with my expectation of returning empty parameter values.  
      Apparently that is not a good idea.  
      Subscribing to this published value from this Invoked Runbook call causes the dreaded "Error initializing extension" in the OOTB Run .NET Script activity.  In this IP, the activity returns success, but nothing else. No published values other than Process id, activity start time, activity end time and activity status.  Checking for the presence of results before parsing the values in the invoked runbook solved the problem.  Also found this caused the issue in a powershell activity within the same runbook just having the [Field()] using the published value from the query when no rows are returned.
      
      The ultimate fix was to initialize a powershell variable with the contents of the published value.  Then if results were present (rows > 0) use the Split(";") method on the variable to get the individual column values.
      
      Hopefully this post saves someone else from this obscure little gotcha.
      
      I am now truly enJOYing this IP!
    • PowerShell Script Execution IP - so there is no way to "Published Data" for a variable. I only get filtered results. I have tried global variables like "{Var1} = get-service", I have tried Run behavior – flatten to global variables like {Var1}. I have tested Publish data on the link, and Script 01 Data Output” in different ways?
      
      I agree to Jim In Idaho if the "Published Data" have been there on the activity, this had been a killer IP.
    • Hi again, I get a bit closer to what I looking for but I have to jump over the action "Send Platform Event". Still a bit difficult to Control the Out put data.
  • Non-static method requires a target.
    2 Posts | Last post July 20, 2016
    • We're receiving the following error when using the OIP objects however the script (shown at the bottom) runs fine locally on the server.
      
      Non-static method requires a target.
      
      Exception: PSRemotingTransportException
      Target site: PowerShell.CoreInvoke
      
      Stack trace:
         at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input, PSDataCollection`1 output, PSInvocationSettings settings)
         at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
         at System.Management.Automation.PowerShell.Invoke()
         at ExecutePS.PSConnectAndExecute.ExecutePS(String authMethod, String uri, String account, String inputPassword, String script, Int32 connTimeout, Int32 scriptTimeout, Boolean executeAsync)
         at ExecutePS.ExecutePSScriptGlobal.Execute(IActivityRequest request, IActivityResponse response)
      
      ####SCRIPT####
      $filter = "*[System[(EventID=201) and TimeCreated[timediff(@SystemTime) <= 1200000]]]" # event id 201 in the last 20 minute
      $message = "Task Scheduler successfully completed task ""\Dsp.Service * - Get Work Date Properties"" , instance ""*"" , action ""C:\Windows\SYSTEM32\cmd.exe"" with return code 0."
      $events = Get-winevent  Microsoft-Windows-TaskScheduler/Operational  -FilterXPath $filter -ErrorAction Continue
      $events = $events | ?{$_.Message -like $message}
      if($events.Count -eq 0)
      {
      exit 1
      } 
      exit 0
      
    • I removed the last few lines of code and added $events for the variable - all is working.
  • How do I based on result value do something within a orchestration
    1 Posts | Last post November 03, 2015
    • Hi
      If I have a Powershell script that looks for a value in a database. If value > 0 I want my orchestrator to trigger Another ps script. If value = 0 I want orchestrator to send platform event.
      Is this possible?
      
      Thanks
  • Help with basic get-ADuser user
    2 Posts | Last post August 07, 2015
    • Trying to run a simple get-ADuser but getting error:
      
       "Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web Services"
      
      Anything special I need to do or be aware off?  I've verified importing of the AD module was successful (AD PowerShell feature installed on the server).  Just the get-ADUser AD call is having the issue.  Same code running in the PowerShell ISE on the specified server list in the Host Name field works fine.
       
      
      # Script
      Import-Module ActiveDirectory
      $aduser = Get-ADUser djohn
      $aduser.Name
      $error
      
      
      #return result: Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web Services
    • I figured out my issues.  I had to enable CredSSP and set my server that's executing the script as the CredSSP Server.
      
      
      
      System Requirements
      
      System Center 2012 Orchestrator (SP1+)
      System Center 2012 Orchestrator Integration Toolkit (SP1)
      Microsoft .NET 3.0 Framework
      PowerShell 2.0+
      winrm quickconfig command executed on local and target machines where PS Scripts will be executed
      Enable-WSManCredSSP for Client and Server roles as needed if CredSSP functionality is desired
  • Published Data?
    1 Posts | Last post November 06, 2014
    • Is it not possible to create your own published data from this activity?
  • Using this IP I can not use the following script to query remote machine in the same domain
    1 Posts | Last post June 23, 2014
    • Harish sankar S	Connecting to remote server failed with the following error message : The WinRM client cannot process the request. Default authentication may be used with an IP address under the following conditions: the transport is HTTPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to set TrustedHosts run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.
      Exception: PSRemotingTransportException
      Target site: AsyncResult.EndInvoke
      	3:55 PM
      	Stack trace:
         at System.Management.Automation.Runspaces.AsyncResult.EndInvoke()
         at System.Management.Automation.Runspaces.Internal.RunspacePoolInternal.EndOpen(IAsyncResult asyncResult)
         at System.Management.Automation.Runspaces.Internal.RemoteRunspacePoolInternal.Open()
         at System.Management.Automation.Runspaces.RunspacePool.Open()
         at System.Management.Automation.RemoteRunspace.Open()
      	
      at ExecutePS.PSConnectAndExecute.RunspaceConnect(String authMethod, Uri uri, String psSchema, PSCredential psCred, Runspace& psRunspace, Int32 connTimeout, Int32 scriptTimeout, Boolean executeAsync)
         at ExecutePS.PSConnectAndExecute.ExecutePS(String authMethod, String uri, String account, String inputPassword, String script, Int32 connTimeout, Int32 scriptTimeout, Boolean executeAsync)
         at ExecutePS.ExecutePSScript.Execute(IActivityRequest request, IActivityResponse response)
  • SQL Connection problem
    2 Posts | Last post February 25, 2014
    • Using this integration pack I can't use the following simple code to query SQL Server:
      
      $DataSource = "SQLSERVER"
      $Database = "DBNAME"
      $SQLConnectionString = “Server=$DataSource;Initial Catalog=$Database;Integrated Security=True;”
      
      $SQLConnection = New-Object System.Data.SqlClient.SqlConnection
      $SQLConnection.ConnectionString = $SQLConnectionString
      
      $SQLConnection.Open()
      
      $Result = $SQLConnection.State
      
      $Result
      
      $Result variable always contains "Closed" (so my understanding is that the SQL Connection does not open successfully.
      
      If I execute the same code with the defaut "Run .NET Script" activity it works fine...
      
      Any ideas ?
    • You are correct, it is failing to make the connection.
      
      If you add a $error at the end of the script, you will see the following error is being hidden by normal execution (without the $error):
      
      "Exception calling "Open" with "0" argument(s): "Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.""
      
      So, it has to be the fact that this IP is doing PS Remoting, then making the connection to SQL. The integrated security option isn't doing what we expect it to do...
      
      So I tested with a different connection string:
      
      "Server=$DataSource;Initial Catalog=$Database;Integrated Security=False;UID=user;Password=password"
      
      And it worked just fine.
      
      So, the options I see here are leverage the Run .Net Script activity or SQL Authentication within this IP.
  • Access Denied
    2 Posts | Last post January 10, 2014
    • Hi, i am having the problem on this IP too.
      
      I was not able to run on the localhost. I was getting the Access Denied error.
      
      Connecting to remote server failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.
      
      Exception: PSRemotingTransportException
      Target site: AsyncResult.EndInvoke
      
      Stack trace:
         at System.Management.Automation.Runspaces.AsyncResult.EndInvoke()
         at System.Management.Automation.Runspaces.Internal.RunspacePoolInternal.EndOpen(IAsyncResult asyncResult)
         at System.Management.Automation.Runspaces.Internal.RemoteRunspacePoolInternal.Open()
         at System.Management.Automation.Runspaces.RunspacePool.Open()
         at System.Management.Automation.RemoteRunspace.Open()
         at ExecutePS.PSConnectAndExecute.RunspaceConnect(String authMethod, Uri uri, String psSchema, PSCredential psCred, Runspace& psRunspace, Int32 connTimeout, Int32 scriptTimeout, Boolean executeAsync)
         at ExecutePS.PSConnectAndExecute.ExecutePS(String authMethod, String uri, String account, String inputPassword, String script, Int32 connTimeout, Int32 scriptTimeout, Boolean executeAsync)
         at ExecutePS.ExecutePSScript.Execute(IActivityRequest request, IActivityResponse response)
    • I got the result. The localhost seem like not able to run at the Runbook Tester.
      
      The error is gone when i tried to execute as normal.
  • Running from LocalHost
    3 Posts | Last post September 30, 2013
    • I LOVE THIS IP !
      My only problem is I cannot get it to work on the localhost.  Can anyone tell me how to get this to run on the localhost?
      
      By the docs I read http://msdn.microsoft.com/en-us/library/aa384295(VS.85).aspx WinRM authentication which says I should use negotiate when using localhost or 127.0.0.1.  HOwever I have used every type and I cannot seem to get it to work.  Could someone share their full settings to get this to work on the localhost (I don't want to hard code a server in there as we have many runbook servers).
      
      Thanks 
    • Thanks for the kind words.
      
      As far as working with 'localhost' - it works in my environment, what error is being returned? (Note: Add $error to the end of the script to see error output for this IP).
      
      For my configuration:
      
      PS Script 01: Get-Process
      Auth: Default
      Host Name: localhost
      Port: 5985
      Domain: contoso
      User: Administrator
      
      It should work with 'localhost', but if it doesn't, try leveraging Published Data in the Host Name field, something like {Runbook Server Name from ...} - this published data can be found after checking the box for "Show common Published Data".
      
      Of course, if you are using the "...Global" activity in this IP, then you will not be able to leverage Published Data for Host Name unless you are using the latest IP version. I will be releasing a full new OIP for this version this week. If you need it sooner than that, you can follow the instructions in the blog post comments to grab the latest DLL: http://sdrv.ms/10dEvfQ is still active and should take you to the download location (skydrive) for the following ZIP file "ExecutePS_1.0.0.2".
    • BTW - The link to the original blog post (for instructions on how to use the 1.0.0.2 DLL) is: http://blogs.technet.com/b/privatecloud/archive/2013/01/31/automation-orchestrator-integration-pack-for-powershell-script-execution.aspx
      
      Read through the comments.
      
      I will update this TechNet Contribution with the latest version and information later this week.