Orchestrator + powershell script: variable

Hello

I want to create a workflow with an external script powershell and "scriptable task."

First step:

1. I set my input parameters in the "Task Scriptable" and "script" my variable entry for the external script powershell tab: scriptArgs = Variable1 + "" + Variable2;

2. I get my variable in my outside first PowerShell script-> at this point it's OK

3. in my outside first powershell script, I create variables $var1 and $var2

Second step:

1. I created a 'Scriptable task' and I want to get an exit powershell ($var1 and $var2) as a starter for my 'scriptable task. "

I don't know how passing a powershell variable to any other 'workflow element' or 'scriptable task. "

Invoke an external PS workflow script returns as objects of the output of type PowerShell:PowerShellRemotePSObject.

You can use it to extract data from the output of the powershell script. Example is provided with the plugin inside the folder library/PowerShell/samples/list directory content workflow

You can use PowerShell:PowerShellRemotePSObject to receive the output as raw xml, PowerShell:PowerShellRemotePSObject.getXml() data or using getRootObject() directlyas objects of type PowerShellPSObject, and then use getProperty (xxx)...

Here is an excerpt of the example workflow to browse the list of files returned as a result of the invocation of the ps script.

  // Get PowerShellRemotePSObject
  var psObject = invResult.getResults();
  var directories = psObject.getRootObject();

  var isList =  directories instanceof Array
  if ( isList ){
  for (idx in directories){
  var item = directories[idx];
  if ( item.instanceOf('System.IO.FileInfo') ){//check type of object
  System.log( item.getProperty('FullName') );//extract value from result
  }
  }
  } else {
  System.log( directories.getProperty('FullName') );//extract value from result
  }
  }
...

Tags: VMware

Similar Questions

  • Get-QADComputer fails if run PowerShell script through Orchestrator workflow

    I use the "Get-QADComputer" cmdlet in my .ps1 script that is supposed to run via Orchestrator.  I have several PowerShell scripts started by Orchestrator and run on a host windows without any problem.  For this script, I have these 2 commands and still error.  The script does not error when run locally.

    Add-PSSnapin Quest.ActiveRoles.ADManagement - ErrorAction SilentlyContinue

    $Computer = get-QADComputer-identity "server01" | where {$_.name - eq "server01"}

    In troubleshooting, I ran Get-PSSnapin and can see that the snap for AD is loaded successfully.  I tried Connect-QADService and who also gives the same error, although it works very well on place.

    I use vCO 5.1.1. device.   On the hosts Windows where are the scripts PowerShell, the AD snap is version 1.6.0.2683.

    Here is the error in the logs Orchestrator...

    PowerShellInvocationError: Errors found during execution of script

    System.Runtime.InteropServices.COMException (0x8007054B): the specified domain does not exist or could not be contacted.

    at Interop.ActiveDs.IADsOpenDSObject.OpenDSObject (String lpszUserName, String lpszPassword, String lpszDNName, Int32 lnReserved)

    to Quest.ActiveRoles.ArsPowerShellSnapIn.DirectoryAccess.AdsiDirectory.NativeBind (adsPath String, AuthenticationTypes bindFlags)

    at Quest.ActiveRoles.ArsPowerShellSnapIn.DirectoryAccess.AdsiDirectory.BindToObject (String dn)

    at Quest.ActiveRoles.ArsPowerShellSnapIn.DirectoryAccess.ConnectorFactory.Create (String serverName, user String, SecureString password, type of ConnectorType)

    to Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.ConnectionAwareCmdlet.EstablishConnection (ConnectionProperties connectionProperties)

    at Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.ConnectionAwareCmdlet.GetContainer)

    at Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.GetUserCmdlet.BeginProcessing)

    at System.Management.Automation.Cmdlet.DoBeginProcessing)

    at System.Management.Automation.CommandProcessorBase.DoBegin)

    (Name of the dynamic Script Module: invokeScript #14)

    Thanks for the info.  I use the workflow "Invoke an external script" to run many of my host admin PowerShell scripts.  It is easier for me to keep all .ps1 files in one place and not import them into Orchestrator.  The article prompted me to switch my connection to host basic Powershell to Kerberos.  To do this, I had to update /etc/krb5.conf on the device of the vCO.  I've referenced VMware KB2036986 to work around the problem "unable to get kdc for the Kingdom.  This issue was mainly because we couldn't have krb5 configured previously.

    Now, I got a different error during execution of the workflow after bouncing vCO.

    System.NullReferenceException: Object Reference not set to an instance of an object.

    Has pointed out me the need to first make the connection AD.  He has not worked before without Kerberos authentication.  Once I added these lines of code, Get-QADComputer finally worked without error!   Thanks for the help.

    $pass = ConvertTo-SecureString - AsPlainText-Force - String "password".

    Connect-QADService - "example.com\serviceaccount" ConnectionAccount - ConnectionPassword $pass

    $Computer = get-QADComputer-identity "server01" | where {$_.name - eq "server01"}

    Disconnect-QADService

  • PowerShell script and the Orchestrator

    Hi guys

    We managed to set up the PowerShell script to run a task in the Orchestrator, the only problem is that we cannot pass the input parameter

    $vCOuser = "xxxxxxxx".

    $vCOpass = "zzzzzzzz.

    $vCOparm = "C:\orchestrator\Test.html".

    # Se connect to vCO and generate proxy $vcoWS

    $vcoWS = New-WebServiceProxy - Uri http:// < server >: 8280/vmware-vmo-webcontrol/webservice? WSDL

    # Print the result

    $vcoWS

    # Find Workflow

    $workflow = $vcoWS.getWorkflowsWithName ("create a simple XML document", $vCOuser, $vCOpass)

    # Print the result

    $workflow

    foreach ($element in $workflow)

    {

    $element.id

    #... and run

    $workflowToken = $vcoWS.executeWorkflow ($element.id, $vCOuser, $vCOpass, inParameters)

    # Print the result

    $workflowToken

    }

    Any help would be appreciated

    Hello!

    You can specify an array of WorkflowtokenAttribute objects and pass it to the executeWorkflow method:

    $inparams += New-Object -TypeName VCO.WorkflowTokenAttribute
    $inparams[0].name = "inputString"
    $inparams[0].type = "String"
    $inparams[0].value = "Hello World"
    
    $inparams
    
    # ... and exectue (use $null instead on $inparams if Workflow has no input parameters
    # ... und ausführen
    $workflowToken = $vcoWS.executeWorkflow($workflow.id, "vcoadmin1" , "VMware2010", $inparams)
    $workflowToken
    

    See the complete example here:

    http://www.vcoportal.de/2011/06/updated-calling-VCO-workflows-from-PowerShell/

    http://www.vcoportal.de/examples/PowerShell-VCO/

    Kind regards

    Joerg

  • Newbie question - tide may run a remote PowerShell script or BAT file?

    My first post.  I am new to raz, but I've had experience with other planners.

    I have a PowerShell script that must be run on a remote computer.  All the script needs software is installed on this computer.

    In addition, I need the script runs under a service account.  Is it possible and if yes, how can I go about it?

    This work will be be launched manually whenever this is necessary.

    Sure. There are some screenshots. A variable one, I used for the location of the folder on the server of tide (not required but I use a lot of scripts). One for the command of tide itself. The last one is the script runs remotely on windows work. Let me know if they don't make sense.

  • Run the powershell script in Workflow VCO

    Hi guys,.

    I'm pretty new to VCO and I am facing difficulties to get what I want. For you, this will be a Basic... but here's my question:

    I have a WF that I use in the WFStubmachineprovisionning that can generate me a name of virtual machine based on the selection of the user while he asked for a virtual computer in the VRA.

    The VM provisionned name looks like this: W203PKLXXX and I need to replace the XXX with a number that is available on the network.

    To do this, I need to query the DNS to see if there is, if not, 002 001... And so on... until an available and I send the full name of the virtual machine to the WF Stubprovisionning.

    This my first try to interact between VCO and a Powershell script. I can run script PS on my host configured, but do not know how to send variables to the custom WF that generates the name of the script of PS and send the name of VM from the script of the PS to the next step.

    Can someone give me a sample of variable to manage? I can't find anything on the net

    Just to tell you that I managed.

    the PS has returned an XML object, not a string. I had to use the method getxml() javascript property, and parse the string to get the value I need

    I also had to blind correctly (getxml) entry and exit (PS)

    If needed I can send you a few screenshoot

  • PowerShell Script - Annotations to CSV

    Hello everyone!

    I need a liitle powershell script that does the following.

    Get all the VM and when "CustomAttribute" is set to 1, write the values such as CPU, RAM,... in a csv file.

    I tried like this:

    $VMExport = get - VM | Get-Annotation CustomAttribute - Export | Where-Object {$_.} {Value - eq 1}

    But now, I have only the value 1 in the Variable '$VMExport' and can not use it for more things.

    Can someone help me with this?

    The CustomFields is a hash table, you can access the values by using the key as the index.

    You will need to use a property calculated for this

    $VMExport = Get-VM | where {Get-Annotation -Entity $_ -CustomAttribute Export | Where-Object {$_.Value -eq 1 }} |
    Select Name,ProvisionedSpaceGB,MemoryMB,NumCpu,Description,   @{N="Custom Field";E={$_.CustomFields["CustomFieldName"]}}
    

    It retrieves the value of the custom field called 'CustomFieldName' and it appears under the "Custom Field" property.

  • How to run multiple Powershell scripts in PowerCLI

    I have a large number of scripts that I would run into lots of PowerCLI. I found a way to call some Powershell scripts from a file of commands like the following (with the permission of Jan Egil Ring), which works very well except for scripts PowerCLI where a connection to a VC or ESX Server must be established before the script can be executed:

    PowerShell-command '& C:\MyScripts\script1.ps1 '.

    PowerShell-command '& C:\MyScripts\script2.ps1 '.

    PowerShell-command '& C:\MyScripts\script3.ps1 '.

    If a VC connection is on using Connect-VIServer PowerCLI, then scripts can each be run from the prompt without connection information and credentials, however, if scripts are placed in a file of DOS commands, it is necessary to place an order Connect-VIServer in each script, which will prompt you for credentials every time , so if I have 10 scripts, I will have to enter the credentials of 10 times. Is it possible to establish the connection and then run a set of Powershell scripts, or is there a way to integrate the identification information in the script so that it will connect to the VI server without asking confirmation?

    Thank you

    Ed Z

    2 options 1 persist credentials on disk, you can find the code on poshcode.org to do.

    Option 2 is to use - Session when using Connect-VIServer. The session is stored in the variable $defaultVIServer. If write you it to a file you can load this file and re-use this same session, assuming that it is still valid (i.e. it has not expired.)

  • Such a powershell script exist?

    Windows Server Standard 2012R2. I know not enough about powershell scripts to be dangerous. So I guess that its better to ask for help on this one. As you know, in the Windows backup program, the e-mail feature is depreciated on server 2012. However, I had no problem of customization of a powershell script that I found so that it sends an email when the nightly backup is completed successfully. Te was easy to do. In Manager tasks I just put the firing an event, with the event being backup Windows and a number of event 4 - which means backup completed successfully. In fact, it works very well for my clients.  But it is not the fault of my client. (of course!)

    Customers only the desire to receive an email if the backup is not successful. But the reasons for a backup failed are many which can generate any number of errors in the event log. Since I'm just not knowledgeable of powershell scripts, I hope someone can help me here, or at least direct me to where I can get help. Basically, I need a script powershell like this:

    Trigger is "the eventID 14 (completed backup operation).

    If eventID in the Microsoft-Windows-backup/OPerational log prior to the triggering event is not 4, while sendmail

    This above would of course, include my work already sendmail script. Is this possible? Maybe someone has already done? Any help would be appreciated.

    Hello

    For technical support, repost the question in the Windows Server Forum.

    https://social.technet.Microsoft.com/forums/WindowsServer/en-us/home

  • Publishes a PowerShell Script

    I have a system which gives some issues where I have to restart some services from time to time.

    The problem is that these are problems on the server for a period of work of China - so I'm Home sleep away.

    I can easily restart services using PowerShell, so I thought I have publish a PowerShell script that one guys can run from AppPortal.

    Thought it would be easy (probably is and my brain doesn't work)...  Publish path to powershell (C:\windows\...) and use the file "path\to\script.ps1" as an argument - however, I can't seem to make it work.

    So, how in the heck would I do this?

    Hey Mike,

    Is this a problem of execution policy? You can try adding '-ExecutionPolicy Unrestricted ' at the command line?

    Adam

  • PowerShell script

    Hello

    Say I want to install the Microsoft Patches each month on a field with 50 + servers. I need a script that could give me the following,

    (i.) the availability of each server present in the field, while running the script.

    II.) he should list on the fixes that have been set up so far and this should be exported to excel.

    Servers are 2003 & 2008. Also, I'm not particularly on Powershell scripts. So anything that meets the objective would be really useful.

    Please help me with this.

    Thank you much in advance.

    René-coral. (* E-mail address is removed from the privacy *)

    This issue is beyond the scope of this site and must be placed on Technet or MSDN

    http://social.technet.Microsoft.com/forums/en-us/home

    http://social.msdn.Microsoft.com/forums/en-us/home

  • How to change power mode using powershell script?

    In Windows 7, there are 2 available for selection (balance or eco) power switch mode.

    I would like to know if it is possible to script powershell code to pass these 2 modes of window 7 or not.

    Does anyone have any suggestions?

    Thanks in advance for your suggestions

    Hello

    You want to know about the encoding of a PowerShell script, I recommend that you post the question on the Forum on TechNet script where you will have the best support for any problem related to scripts.

    http://social.technet.Microsoft.com/forums/scriptcenter/en-us/home?Forum=iTCG

    Thank you.

  • The Scripts PowerShell Script to remove AD Logon

    I'm trying to create a PowerShell script to remove the scripts of connection for all users in the AD.

    I'm trying to create a PowerShell script to remove the scripts of connection for all users in the AD.

    Hello

    Your question is addressed in these forums of consumers.

    Please use the following to ask this question.

    Windows 8 IT Pro category:

    http://social.technet.Microsoft.com/forums/en-us/category/w8itpro

    Concerning

  • In the Powershell script execution error: could not find the type [ordered]: make sure that the assembly containing this type is loaded.

    People,

    I am trying to load and run the PowerShell script of PowerCLI Module to check the CPU, memory and storage overcommitment. VMware PowerCLI Blog - VMware Blogs but somehow it is always stopped with the error: cannot find the [ordered] type: make sure that the assembly containing this type is loaded.

    Here are some of the diagnostic result:

    $PSVersionTable

    Value name

    ----                           -----

    PSVersion 2.0

    PSCompatibleVersions {1.0, 2.0}

    BuildVersion 6.1.7601.17514

    PSRemotingProtocolVersion 2.1

    WSManStackVersion 2.0

    CLRVersion 4.0.30319.1026

    SerializationVersion 1.1.0.1

    Get-ChildItem ' HKLM:\SOFTWARE\Microsoft\NET frame Setup\NDP'-recurse |

    Get-ItemProperty-name of the EA - 0 Version |

    Where {$_.} PSChildName-match ' ^ (?) (S) \p {L} "} |"

    Select PSChildName, Version

    PSChildName Version

    -----------                       -------

    v2.0.50727 2.0.50727.5420

    3.0.30729.5420 v3.0

    Windows Communication Foundation 3.0.4506.5420

    Windows Presentation Foundation 3.0.6920.5011

    3.5.30729.5420 v3.5

    Customer 4.0.30319

    4.0.30319 full

    Get-PowerCLIVersion

    PowerCLI Version

    ----------------

    VMware vSphere PowerCLI 5.8 Release 1 build 2057893

    ---------------

    Versions of the snap

    ---------------

    Build VMWare AutoDeploy PowerCLI component 5.5 1983942

    Build VMWare ImageBuilder PowerCLI component 5.5 1983942

    Build license of VMware PowerCLI component 5.5 1265954

    Build VMware Storage PowerCLI component 5.8 2057894

    Build VDS's VMware PowerCLI component 5.8 2031581

    Build VMware vSphere PowerCLI component 5.8 2031581

    I installed Windows6. 1 -KB2819745- x 64 - MultiPkg.msu to enable Powershell v4.0 on my Windows 7 laptop, but still the script cannot be executed with the above error message.

    Any kind of aid and assistance would be greatly appreciated.

    Thank you

    Hello-

    Ah, yes--it is that review.

    Another option, because you are not able to go to .NET FX 4.5, is to remove the parts "[ordered]' of the code that you use.  This type Accelerator makes the hash table a dictionary sorted.  The effect to remove that from the code will be that the properties of the object that results will not be in the order in which they appear in the code.

    And, another option would be to install PowerShell v3 (the version in which the '[ordered]' feature has been added').  That shouldn't require a FX .NET newer than what you showed as having already installed on this computer.  However, as we have seen with the PSSnapin and PSv4 Exchange, you want to make sure that the PSSnapins / Modules you want to use are compatible with PowerShell v3.

  • Struggling to run Powershell scripts / commands

    Hi all!

    I'm fighting to get the Powershell vCO workflow.  I think I missed something really obvious, but I can't see it...

    I did the set Kerberos in place on the line of my vCO 5.5.2 machine.  I added a Powershell v2 host using VMWare provided Powershell 1.0.4 workflows plugin install, Kerberos authentication and using a shared account (mine, I know that I am an admin on Windows Server).  I assured the Kerberos authentication and unencrypted traffic is accepted on the Powershell host.  If I validate the object created at the CVO, he says it's fine.

    When I come to run another VMware provided workflow, I get responses to error because the workflow doesn't seem to be properly trained, or I get a null response.  When I run a workflow, I can see my account by logging in the Windows Server 2008 security log, so I'm pretty confident that the basic connection and portions of Kerberos are all ok.

    I just tried to simplify a VMware provided workflow, to make it as a possible base (code below).  I always get a Null response.  Anyone have any ideas why?  Or did someone is able to provide the code for a very simple Powershell-based workflow that they know works so I can test it on my set up?

    The VMWare-based simple powershell script provided one to get the contents of some directories and the values that I use - it returns null:

    the hostentry, type: PowerShell:PowerShellHost, value: < myPowershellHostSelectedFromPluginManually >

    Directoryentry, type: String, value: I manually enter $home.  Or C:.  Or C:\Windows.  Or any other directory I know there is that my user account has no light problem.

    output of the result, type: string, value: regardless of the ("DIR" + directory) output >

    var Sess;

    connect to the host

    Sess = host.openSession)

    Send the command in powershell

    sess.addCommandFromString ("dir" + directory)

    invoke the command

    invResult = sess.invokePipeline ();

    get the result

    Result = invResult.getResults)

    Send to open a session

    System.log ("Result is" + result)

    Thank you very much in advance!

    And there we go...  Who sets: powershell.exe wasn't in the path of the Windows host!

    Thanks for the help everyone, especially igaydajiev for giving me the pointer of the final to my answer!

  • reviews - type of powershell script script error is not valid for OS null

    I use the comments script manager to run the script on a newly cloned VM Windows Powershell. In my main workflow, I call several workflows VM (upgrade tools, vm stop, move DS, etc.) whose use: attribute called type newVM VC:VirtualMachine. I added a new secondary workflow to run the Script to run as a guest VM. I did like the others under workflow and related virtual machine of the VC:VirtualMachine parameter to the newVM. Also limited the parameters of user name and password. I can run the subworkflow run the Script in guest VM by itself without any problem. However, when I run the main workflow which is the integrated subworkflow, I get this error: powershell script type is not valid for OS null

    Yes there is, when editing a workflow schema in Basic on the left side is a tool of sleep.

Maybe you are looking for

  • What can refresh from mackbook 3.1 under snow leopard 10.6.8

    What can upgrade to more mackook 3.1 under snow leopard 10.6.8. machine is fan swirling a lot.

  • ROIToMask and extracting a region of 16 - bit

    Hello- The ROIToMask function is always incompatible with 16-bit images from 2013 of the Vision.  First of all, I wonder if this has finally been fixed in Vision 2014? Second, I do math on the portion of the extracted image defined by my KING.  So I

  • Bluescreen download McAfee Total Protection

    Hello Can someone please help - I just spent 5 1/2 hours chatting with McAfee, then more with Microsoft but not just anywhere. I uninstalled and I try to reinstall McAfee Total Protection. However, when you try to download the software, I get the blu

  • Why crash Windows Explorer on right click in the left pane?

    In Windows Explorer, the time that I did a right click on any folder in Windows Explorer hangs: "Windows Explorer has stopped working.  A problem caused the blocking of the program works correctly.  Windows will close the program and notify you if a

  • Milchige Bilder, Bilder mit man

    Hallo, bin ganz neu bei Indesign und das habe problem, dass mir Bilder und auch nicht Rechtecke handle in der ursprünglich kraftigen Farbe independent, sondern als ob ein milchiger Film verdecken wurde sie. Wenn ich die Elemente der anklicke und vers