VMware Aria Automation Tools

 View Only
  • 1.  How do i run a simple Powershell script on a machine during deployment in VRA8

    Posted Jul 02, 2021 09:06 AM

    we need to run a simple powershell command on machines as they are provisioned, we have tried creating workflows to do this but its saying the powershell applets dont exist ? 

    Get-Disk we are using, surely this should be something that is simple to do but we cant get it to run successfully at all ?

    prior to vra8 people were saying about using guest tools to do this but this doesnt seem to exist for vra 8 ? the documentation is quite lacking in direction on these things so any advise/help on this matter would be gratefully appreciated 

     



  • 2.  RE: How do i run a simple Powershell script on a machine during deployment in VRA8

    Posted Jul 02, 2021 05:33 PM

    Have you tried using the "Run program in guest" workflow?  I think you can just specify the local path to powershell as the program and the script as arguments.  I could try to come up with a simple example if needed, when I find the time.

    How simple is your simple script?



  • 3.  RE: How do i run a simple Powershell script on a machine during deployment in VRA8

    Posted Jul 19, 2021 02:13 PM

    i will give it a go and let you know, we jsut want to execute a command to install sql server etc 



  • 4.  RE: How do i run a simple Powershell script on a machine during deployment in VRA8

    Posted Jul 13, 2021 01:58 PM

    I've been doing this with ABX actions and Invoke-VMScript.

    Example: https://github.com/jbowdre/misc-scripts/blob/main/vRealize/configure_guest.ps1



  • 5.  RE: How do i run a simple Powershell script on a machine during deployment in VRA8

    Posted Dec 16, 2021 06:17 PM

    Hey, John!

    Is it possible to get the vcenter address or fqdn from the vRA in the ABX code?



  • 6.  RE: How do i run a simple Powershell script on a machine during deployment in VRA8

    Posted Dec 16, 2021 06:45 PM

     it seems like it should be but I wasn't able to find a way to do that short of passing it in as a custom property from the cloud template. I put together some notes on how I'm handling it here, in case you're interested.



  • 7.  RE: How do i run a simple Powershell script on a machine during deployment in VRA8

    Posted Dec 16, 2021 06:54 PM

    Thanks, !



  • 8.  RE: How do i run a simple Powershell script on a machine during deployment in VRA8

    Posted Dec 16, 2021 10:29 PM

    I use subscriptions to run Powershell code to install applications, AD work post build. I have found ABX has some issues/limits with Powershell.

    I have a Workflow that has several Actions that run Powershell scripts.

    One of the custom properties in the subscription is vcUuid which I pass into a workflow which returns the "targetvcenterConnection" (See below), once I have the targetVcenterConnection I use that in my vRO Actions to connect to vCenter using normal PowerCLI.

    $vcfqdn $inputs.targetVcenterConnection;
     

    Connect-VIServer $vcfqdn -User $vcUser -Password $vcPass -Force;

    $vmname = "VMNAME";
    $vm = Get-vm -name $vmname;

    $script = "yourscript";
    $runscript = Invoke-VMScript -VM $vm -ScriptText $script -GuestUser $vcUser -GuestPassword $vcPass -ToolsWaitSecs 300;

    You can then check the Exit code

     if($runscript.ExitCode -eq 0)
        {
            $result = 'Complete'
        }
        else
        {
            $result = 'Falied'
        }
     
    ###### Get vCenter connection by UUID  Workflow ####
    ### input:string targetVcenterUuid | output:string: targetVcenterConnection ########
    ##############################################################
    var connections = VcPlugin.allSdkConnections;
    for (i=0; i<connections.length;i++) {
      if (connections[i].about.instanceUuid == targetVcenterUuid) {
        targetVcenterConnection = connections[i].id;
      }
    }
     
     
    Hope this helps.


  • 9.  RE: How do i run a simple Powershell script on a machine during deployment in VRA8

    Posted Dec 16, 2021 11:20 PM

    wow, that's cool. One thing I don't get - how do you move from inputProperties.customProperties.vcUuid in the payload to targetVcenterUuid in your workflow?



  • 10.  RE: How do i run a simple Powershell script on a machine during deployment in VRA8

    Posted Dec 17, 2021 01:34 PM
     $targetVcenterUuid = $inputs.inputProperties.customProperties.vcUuid;
     
     $output=@{'targetVcenterUuid' = $targetVcenterUuid}

     return $output
     
    Make sure in the scriptTask you have the targetVcenterUUid in the Outputs.