VMware Cloud Community
ghaithsultaneh
Contributor
Contributor

invoke an external script to create Djoin file

Hi All,

I am trying to provision a computer using Djoin . I created a workflow in VRO to invoke an external script which located on powershell host , so it works without errors but no blob file was created on powershell host .

when i run the script locally on the powershell host it works and the file is created . I already checked the script and i think that the problem is ,that when i am invoking the 'djoin,exe' from vrealire orchestrator through powershell host , it is not responding .But it responds when i run the script locally on powershell host .

I am also not recieving any errors regarding the credentials . so how could i resolve this issue ?

the code :

[CmdletBinding()]

param(

  [parameter(Mandatory = $true)]

  [string]$ADUsername,

  [parameter(Mandatory = $true)]

  [string]$ADPassword,

  [parameter(Mandatory = $true)]

  [string]$ComputerOU,

  [parameter(Mandatory = $true)]

  [string]$ComputerName,

  [parameter(Mandatory = $true)]

  [string]$OutputFolder,

  [switch]$reuse

)

try {

  $SecurePassword = ConvertTo-SecureString $ADPassword -AsPlainText -Force

  $cred = [PSCredential]::New($ADUsername, $SecurePassword)

    

  $ProvisioningFilePath = "$($OutputFolder)\$($ComputerName).txt"

 

  $excluded = ('aa', 'bb', 'cc')             #domains

  $location = $ComputerOU.Split(',') | Where-Object { $_ -like 'DC=*' } | ForEach-Object { $_.Split('=')[1] } | Where-Object { $_ -notin $excluded }

  $DomainName = "$location.domainname"

  $ComputerOU = '"' + $ComputerOU + '"'

  if ($reuse) {

    $Cmd = @{

      FilePath     = (Join-Path -Path ([System.Environment]::SystemDirectory) -ChildPath 'djoin.exe')

      ArgumentList = "/PROVISION /DOMAIN $DomainName /MACHINE $ComputerName /MACHINEOU $ComputerOU /SAVEFILE $ProvisioningFilePath /reuse"

       }

       Write-Output('Provisioning successfull with reuse')

  }

  else {

    $Cmd = @{

      FilePath     = (Join-Path -Path ([System.Environment]::SystemDirectory) -ChildPath 'djoin.exe')

      ArgumentList = "/PROVISION /DOMAIN $DomainName /MACHINE $ComputerName /MACHINEOU $ComputerOU /SAVEFILE $ProvisioningFilePath"

    }

    Write-Output('Provisioning successfull')

  }

  try {

    Start-Process @Cmd -Wait -PassThru -Credential $cred | Out-Null

   

  }

   catch {

    #skip

  }

 

  $ProvisioningFilePath

 

}

catch {

  Write-Host 'Script, '$MyInvocation.MyCommand.Name' caught exception: '$_.Exception.Message

  exit 255

}

Reply
0 Kudos
0 Replies