<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: vRA 7.6 software component powershell create OU and join VM fails with exit value 1 in VMware Aria Automation Tools Discussions</title>
    <link>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824701#M13147</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've solved this. Problem is Get-ADorganizationalunit in addition with -Identity parameter because it will give us an error OU in Active Directory not found if the OU doesn't exist. vRA takes this "error" and give it as exit=1 back and stop the deployment / decomission the VM because of that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To solve it easily use Get-ADOrganizational Unit with -FIlter parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your input.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Jun 2020 12:26:38 GMT</pubDate>
    <dc:creator>n8watcher</dc:creator>
    <dc:date>2020-06-12T12:26:38Z</dc:date>
    <item>
      <title>vRA 7.6 software component powershell create OU and join VM fails with exit value 1</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824693#M13139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi together,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hopefully someone could help because I'm getting crazy with this problem.&lt;/P&gt;&lt;P&gt;My plan is to deploy a VM with vRA 7.6 and everything works exept the powershell software component.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This powershell script should only get the variable from custom form and check the AD if OU exists or not, create if not exist and join the VM to domain.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;# username password for AD join&lt;/P&gt;&lt;P&gt;$password = "xxx" | ConvertTo-SecureString -asPlainText -Force&lt;/P&gt;&lt;P&gt;$username = "xxx" &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$ADcredential = New-Object System.Management.Automation.PSCredential($username,$password)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Set DomainController for specific Domain&lt;/P&gt;&lt;P&gt;$domainController = (Get-ADDomainController -Domain $Domain -Discover -Writable -SiteName "Backbone").HostName[0].ToString()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try{&lt;/P&gt;&lt;P&gt;Get-ADOrganizationalUnit -Identity $TargetOU -Credential $ADcredential -Server $domainController&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;catch{&lt;/P&gt;&lt;P&gt;New-ADOrganizationalUnit -Name $createOUName -Path "$CreateOUPath" -ProtectedFromAccidentalDeletion $false -Credential $ADcredential -Server $domainController -ErrorAction Ignore&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;#AD join&lt;/P&gt;&lt;P&gt;Add-Computer -DomainName $Domain -OUPath $TargetOU -Credential $ADcredential -Server $domainController -PassThru -Verbose #-Restart&lt;/P&gt;&lt;P&gt;$LASTEXITCODE = 0&lt;/P&gt;&lt;P&gt;$LASTEXITCODE&lt;/P&gt;&lt;P&gt;exit&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;( code insertion doesn't work as expected &lt;img class="lia-deferred-image lia-image-emoji" src="https://communities.vmware.com/html/@8D3AC78033E090809829B1C8262B7619/emoticons/1f61e.png" alt=":disappointed_face:" title=":disappointed_face:" /&gt; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I've checked:&lt;/P&gt;&lt;P&gt;- if the OU exist the PS script is working and join the new VM to the given OU&lt;/P&gt;&lt;P&gt;- when I've changed $createOUPath variable to a static entry the PS script is working and a new OU is created and VM joined to this OU&lt;/P&gt;&lt;P&gt;- when I execute the script locally on a VM template it is working without any error&lt;/P&gt;&lt;P&gt;- I've added &lt;SPAN style="background-color: #f6f6f6;"&gt;$LASTEXITCODE and -ErrorAction Ignore and still getting: "&lt;SPAN style="color: #565656; font-family: Metropolis, 'Avenir Next', 'Helvetica Neue', Arial, sans-serif; font-size: 13px;"&gt;ABORT. Encountered error in Powershell. Error while executing script: Process exited with an error: 1 (Exit value: 1)" but $LASTEXITCODE is shown with value 0?!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6; color: #565656; font-size: 13px; font-family: Metropolis, 'Avenir Next', 'Helvetica Neue', Arial, sans-serif;"&gt;So I know that the problem is the $CreateOUPath variable because (as mentioned above) when I'll enter there static entry it works.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6; color: #565656; font-size: 13px; font-family: Metropolis, 'Avenir Next', 'Helvetica Neue', Arial, sans-serif;"&gt;Did someone know what I'm doing wrong?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6; color: #565656; font-size: 13px; font-family: Metropolis, 'Avenir Next', 'Helvetica Neue', Arial, sans-serif;"&gt;Thank you guys.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2020 14:25:34 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824693#M13139</guid>
      <dc:creator>n8watcher</dc:creator>
      <dc:date>2020-06-09T14:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: vRA 7.6 software component powershell create OU and join VM fails with exit value 1</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824694#M13140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use a &lt;SPAN style="font-family: courier new, courier;"&gt;Write-Output&lt;/SPAN&gt; statement in your catch block just before invoking &lt;SPAN style="font-family: courier new, courier;"&gt;New-ADOrganizationalUnit&lt;/SPAN&gt;. Show the output from a failed run to see what value is present. Also, remove double quotes around that variable as it's not needed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2020 14:33:50 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824694#M13140</guid>
      <dc:creator>daphnissov</dc:creator>
      <dc:date>2020-06-09T14:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: vRA 7.6 software component powershell create OU and join VM fails with exit value 1</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824695#M13141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi daphnissov,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've reworked the script with your recommendations and get following error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN style="color: #565656; font-family: Metropolis, 'Avenir Next', 'Helvetica Neue', Arial, sans-serif; font-size: 13px;"&gt;New-ADOrganizationalUnit -Name TestDL28 -Path OU=TEST,DC=test1,DC=test,DC=intern -ProtectedFromAccidentalDeletion False -Credential UserName Password -------- -------- XXXX System.Security.SecureString -Server DC01.test1.test.intern Add-Computer : Computer 'vRAtestAD36' failed to join domain 'test1.test.intern\DC01.test1.test.intern' from its current workgroup 'WORKGROUP' with following error message: The system cannot find the file specified. At C:\Windows\Temp\fea51b03-d7c5-4457-9875-a0a4da41f126\task.ps1:21 char:1 + Add-Computer -DomainName $Domain -OUPath $TargetOU -Credential $ADcre ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (vRAtestAD36:String) [Add-Comp uter], InvalidOperationException + FullyQualifiedErrorId : FailToJoinDomainFromWorkgroup,Microsoft.PowerShe ll.Commands.AddComputerCommand 0 True ABORT. Encountered error in Powershell. Error while executing script: Process exited with an error: 1 (Exit value: 1)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Dome&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2020 15:24:16 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824695#M13141</guid>
      <dc:creator>n8watcher</dc:creator>
      <dc:date>2020-06-09T15:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: vRA 7.6 software component powershell create OU and join VM fails with exit value 1</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824696#M13142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Forgot that with OU distinguished names they do need to be quoted. Change your script in the software component to enclose that variable in single quotes. You may need to wrap that in double quotes to get the variable to expand properly. I always forget what the order is when getting variable expansion to work but also include quotes. It's either&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new, courier;"&gt;"'myVar'"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new, courier;"&gt;""myVar""&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First is double quotes then single; second is two double quotes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2020 16:09:52 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824696#M13142</guid>
      <dc:creator>daphnissov</dc:creator>
      <dc:date>2020-06-09T16:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: vRA 7.6 software component powershell create OU and join VM fails with exit value 1</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824697#M13143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;""myVar"" didn't returned an error message exept from:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #565656; font-family: Metropolis, 'Avenir Next', 'Helvetica Neue', Arial, sans-serif; font-size: 13px;"&gt;ABORT. Encountered error in Powershell. Error while executing script: Process exited with an error: 1 (Exit value: 1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #565656; font-family: Metropolis, 'Avenir Next', 'Helvetica Neue', Arial, sans-serif; font-size: 13px;"&gt;But VM and OU are created and VM is domain joined but because of error complete deployment faild and VM is decomissioned.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #565656; font-family: Metropolis, 'Avenir Next', 'Helvetica Neue', Arial, sans-serif; font-size: 13px;"&gt;&lt;img class="lia-deferred-image lia-image-emoji" src="https://communities.vmware.com/html/@8D3AC78033E090809829B1C8262B7619/emoticons/1f61e.png" alt=":disappointed_face:" title=":disappointed_face:" /&gt; so same as before. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #565656; font-family: Metropolis, 'Avenir Next', 'Helvetica Neue', Arial, sans-serif; font-size: 13px;"&gt;Didn't get it what is here the problem with the OU Path from custom form. As I said when I only change OU path to static it's working:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #565656; font-family: Metropolis, 'Avenir Next', 'Helvetica Neue', Arial, sans-serif; font-size: 13px;"&gt;Write-Output New-ADOrganizationalUnit -Name "TESTDL" -Path "OU=TEST,dc=test1,dc=test,dc=intern" -ProtectedFromAccidentalDeletion $false -Credential $ADcredential -Server $domainController -ErrorAction Ignore&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2020 18:14:26 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824697#M13143</guid>
      <dc:creator>n8watcher</dc:creator>
      <dc:date>2020-06-09T18:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: vRA 7.6 software component powershell create OU and join VM fails with exit value 1</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824698#M13144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN style="color: #565656; font-family: Metropolis, 'Avenir Next', 'Helvetica Neue', Arial, sans-serif; font-size: 13px;"&gt;As I said when I only change OU path to static it's working:&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;What exactly do you mean? Are you saying if you specify the path in the custom form it works when driven through the software component, or if you invoke the PS manually from an interactive session on the deployed VM? The first is significant; the second not so much.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2020 18:21:37 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824698#M13144</guid>
      <dc:creator>daphnissov</dc:creator>
      <dc:date>2020-06-09T18:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: vRA 7.6 software component powershell create OU and join VM fails with exit value 1</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824699#M13145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I mean when I write the OU path directly into the software component&amp;nbsp; and didn't take the variable it works without any error.&lt;/P&gt;&lt;P&gt;So instead of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_15917653180126241" data-renderedposition="70_8_1233_16" jivemacro_uid="_15917653180126241"&gt;&lt;P&gt;Write-Output New-ADOrganizationalUnit -Name ""$createOUName"" -Path ""$CreateOUPath"" -ProtectedFromAccidentalDeletion $false -Credential $ADcredential -Server $domainController -ErrorAction Ignore&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll fill $CreateOUPath:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15917654017929044 jive_text_macro" data-renderedposition="148_8_1233_16" jivemacro_uid="_15917654017929044"&gt;&lt;P&gt;Write-Output New-ADOrganizationalUnit -Name ""$createOUName"" -Path ""OU=TEST,dc=test1,dc=test,dc=intern"" -ProtectedFromAccidentalDeletion $false -Credential $ADcredential -Server $domainController -ErrorAction Ignore&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first one creates OU and later join VM to domain but throw the mentioned exit error=1.&lt;/P&gt;&lt;P&gt;The second one works like a charm and complete deployment finished successfully.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can it be a bug?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2020 05:06:38 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824699#M13145</guid>
      <dc:creator>n8watcher</dc:creator>
      <dc:date>2020-06-10T05:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: vRA 7.6 software component powershell create OU and join VM fails with exit value 1</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824700#M13146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I understand what you mean by populating the variable manually, but that's not what I was last asking. I'm asking &lt;SPAN style="text-decoration: underline;"&gt;how are you then running it&lt;/SPAN&gt;? Please explain how you supply this variable manually and it runs successfully. Are you doing it from an interaction session (manually, when logged into the system as a user), or are you supplying that value manually in vRA somewhere (on the form, in a software component property, etc.). Please show me what steps you took. It's not a bug; it's either the value is getting invalid characters somewhere, or it's an environmental issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2020 11:00:39 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824700#M13146</guid>
      <dc:creator>daphnissov</dc:creator>
      <dc:date>2020-06-10T11:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: vRA 7.6 software component powershell create OU and join VM fails with exit value 1</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824701#M13147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've solved this. Problem is Get-ADorganizationalunit in addition with -Identity parameter because it will give us an error OU in Active Directory not found if the OU doesn't exist. vRA takes this "error" and give it as exit=1 back and stop the deployment / decomission the VM because of that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To solve it easily use Get-ADOrganizational Unit with -FIlter parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your input.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2020 12:26:38 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation-Tools/vRA-7-6-software-component-powershell-create-OU-and-join-VM/m-p/1824701#M13147</guid>
      <dc:creator>n8watcher</dc:creator>
      <dc:date>2020-06-12T12:26:38Z</dc:date>
    </item>
  </channel>
</rss>

