Hi I am try to use a invoke command to copy files from network file share to a windows servers, but the script fails
my script as follows:
function handler($context, $inputs) {
$script_pass = $context.getSecret($inputs.winpass)
#$script_user = $context.getSecret($inputs.fnjsbuft)
$script_user = 'svc_vcsa01@mydomain.com'
$vcuser = $context.getSecret($inputs.vcUsername)
$vcpassword = $context.getSecret($inputs.vcpassword)
$vcfqdnmv = myvcsa.mydomain.com
$vcfqdndv = "dev-vcsa.mydomain.com"
#$custprop = @{}
#$custprop = $inputs.customProperties
$cp = @{}
#$sqi1 = $custprop.sqi
$name1 = $inputs.resourceNames[0]
$cp.sqif = $inputs.customProperties.sqi
$cp.namef = $name1
Write-Host $sqi1,$name1,$cp.sqi,$cp.name
$sqi = $inputs.customProperties.sqi
$name = $inputs.resourceNames[0]
Write-Host $name,$sqi ,
Start-Sleep -s 30
$vc=Connect-VIServer myvcsa.mydomain.com -User $vcuser -Password $vcpassword -Force
Start-Sleep -s 120
write-host “Waiting for VM Tools to Start”
do {
$toolsStatus = (Get-vm -name $name | Get-View).Guest.ToolsStatus
write-host $toolsStatus
sleep 3
} until ( $toolsStatus -eq 'toolsOk' -or $toolsStatus -eq 'toolsOld' )
$vm = Get-vm -name $name
$output = $inputs.customProperties.osType
$outputenv = $inputs.customProperties.env
$outputsql = $inputs.customProperties.vmfun
$outputimg = $inputs.customProperties.image
Write-Host "VM OS Type is " $output
$windowsString = 'wi'
$windowsString1 = 'WINDOWS'
$envstring = 'sv'
$sqlstring = 'db'
$sqlstring1 = 'sq'
$webstring = 'ww'
$imgstring = 'W2K19_V'
$scriptsq1 = 'Copy-Item -Path "\\192.168.0.76\Install\SQL2019" -Destination "c:\temp\" -Force -Recurse'
$scriptsqi1 = 'C:\Temp\SQL2019\SQLAutomatedScript\BatchFiles>SQLSetup.bat '+$sqi
$scriptsqi2 = $sqi+' |Out-File C:\Temp\sqi.txt -NoClobber'
$s = $scriptsq1+';'+$scriptsqi2
Write-Host $s
$delay = 'Start-Sleep -s 30'
Start-Sleep -s 30
$runscriptsq = Invoke-VMScript -VM $vm -ScriptText $scriptsq1 -GuestUser "$script_user" -GuestPassword "$script_pass" -ToolsWaitSecs 60
Start-Sleep -s 300
#$runscriptsqi1 = Invoke-VMScript -VM $vm -ScriptText $scriptsqi1 -GuestUser "$script_user" -GuestPassword "$script_pass" -ToolsWaitSecs 60
#$runscriptsq.scriptoutput
#return $cp.sqif
}
And here is the error:
devmysql123
devmysql123odsql30Start-Sleep
VERBOSE: Populating RepositorySourceLocation property for module VMware.VimAutomation.Cis.Core.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.VimAutomation.Cis.Core/13.0.0.20797636/VMware.VimAutomation.Cis.Core.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module VMware.Vim.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.Vim/8.0.1.20797199/VMware.Vim.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module VMware.VimAutomation.Common.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.VimAutomation.Common/13.0.0.20797081/VMware.VimAutomation.Common.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module VMware.VimAutomation.Sdk.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.VimAutomation.Sdk/13.0.0.20791442/VMware.VimAutomation.Sdk.psm1'.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.VimAutomation.Cis.Core/13.0.0.20797636/VMware.VimAutomation.Cis.Core.psd1'.
VERBOSE: Populating RepositorySourceLocation property for module VMware.Vim.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.Vim/8.0.1.20797199/VMware.Vim.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module VMware.VimAutomation.Common.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.VimAutomation.Common/13.0.0.20797081/VMware.VimAutomation.Common.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module VMware.VimAutomation.Sdk.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.VimAutomation.Sdk/13.0.0.20791442/VMware.VimAutomation.Sdk.psm1'.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.Vim/8.0.1.20797199/VMware.Vim.psd1'.
VERBOSE: Populating RepositorySourceLocation property for module VMware.VimAutomation.Common.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.VimAutomation.Common/13.0.0.20797081/VMware.VimAutomation.Common.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module VMware.VimAutomation.Sdk.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.VimAutomation.Sdk/13.0.0.20791442/VMware.VimAutomation.Sdk.psm1'.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.VimAutomation.Common/13.0.0.20797081/VMware.VimAutomation.Common.psd1'.
VERBOSE: Populating RepositorySourceLocation property for module VMware.VimAutomation.Sdk.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.VimAutomation.Sdk/13.0.0.20791442/VMware.VimAutomation.Sdk.psm1'.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.VimAutomation.Sdk/13.0.0.20791442/VMware.VimAutomation.Sdk.psd1'.
VERBOSE: Populating RepositorySourceLocation property for module VMware.VimAutomation.Sdk.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.VimAutomation.Sdk/13.0.0.20791442/VMware.VimAutomation.Sdk.psm1'.
VERBOSE: Exporting function 'EnableParameterCompleters'.
VERBOSE: Exporting function 'Get-InstallPath'.
VERBOSE: Exporting function 'Get-PSVersion'.
VERBOSE: Exporting cmdlet 'Get-ErrorReport'.
VERBOSE: Importing cmdlet 'Get-ErrorReport'.
VERBOSE: Importing function 'EnableParameterCompleters'.
VERBOSE: Importing function 'Get-InstallPath'.
VERBOSE: Importing function 'Get-PSVersion'.
VERBOSE: Populating RepositorySourceLocation property for module VMware.VimAutomation.Common.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.VimAutomation.Common/13.0.0.20797081/VMware.VimAutomation.Common.psm1'.
VERBOSE: Exporting cmdlet 'Get-PowerCLIContext'.
VERBOSE: Exporting cmdlet 'Get-Task'.
VERBOSE: Exporting cmdlet 'New-OAuthSecurityContext'.
VERBOSE: Exporting cmdlet 'Stop-Task'.
VERBOSE: Exporting cmdlet 'Use-PowerCLIContext'.
VERBOSE: Exporting cmdlet 'Wait-Task'.
VERBOSE: Importing cmdlet 'Get-PowerCLIContext'.
VERBOSE: Importing cmdlet 'Get-Task'.
VERBOSE: Importing cmdlet 'New-OAuthSecurityContext'.
VERBOSE: Importing cmdlet 'Stop-Task'.
VERBOSE: Importing cmdlet 'Use-PowerCLIContext'.
VERBOSE: Importing cmdlet 'Wait-Task'.
VERBOSE: Populating RepositorySourceLocation property for module VMware.Vim.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.Vim/8.0.1.20797199/VMware.Vim.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module VMware.VimAutomation.Cis.Core.
VERBOSE: Loading module from path '/root/.local/share/powershell/Modules/VMware.VimAutomation.Cis.Core/13.0.0.20797636/VMware.VimAutomation.Cis.Core.psm1'.
VERBOSE: Exporting cmdlet 'Connect-CisServer'.
VERBOSE: Exporting cmdlet 'Disconnect-CisServer'.
VERBOSE: Exporting cmdlet 'Get-CisService'.
VERBOSE: Importing cmdlet 'Connect-CisServer'.
VERBOSE: Importing cmdlet 'Disconnect-CisServer'.
VERBOSE: Importing cmdlet 'Get-CisService'.
DEBUG: Logging in to server.
DEBUG: logged in to server ddev-vcsa.mydomain.com:443
Waiting for VM Tools to Start
VERBOSE: 07/17/2023 08:12:09 Get-View Finished execution
VERBOSE: 07/17/2023 08:12:09 Get-VM Finished execution
DEBUG: 07/17/2023 08:12:09 Get-VM
DEBUG: 07/17/2023 08:12:09 Get-View
toolsOk
VERBOSE: 07/17/2023 08:12:12 Get-VM Finished execution
DEBUG: 07/17/2023 08:12:12 Get-VM
VM OS Type is wi
Copy-Item -Path "\\192.168.0.76\Install\SQL2019" -Destination "c:\temp\" -Force -Recurse;zakodsql |Out-File C:\Temp\sqi.txt -NoClobber
DEBUG: 07/17/2023 08:12:42 Invoke-VMScript 52f808e7-f90e-8d16-a643-fc270d606fc2
VERBOSE: 07/17/2023 08:12:42 Invoke-VMScript Finished execution
DEBUG: 07/17/2023 08:12:42 Invoke-VMScript
Finished running action code.
Exiting powershell process.
Powershell process exited.
Max Memory Used: 346 MB Unable to extract action outputs. Outputs must be a map.
There test is not throwing any error message:
When i tried to maually set the value:
$scriptsq1 = 'Copy-Item -Path "\\192.168.0.76\Install\SQL2019" -Destination "c:\temp\" -Force -Recurse'
I am getting following error log:
VM OS Type is
Copy-Item -Path "c:\temp1\SQL2019" -Destination "c:\temp\" -Force -Recurse; |Out-File C:\Temp\sqi.txt -NoClobber
DEBUG: 07/17/2023 12:03:34 Invoke-VMScript 526102cc-eabb-e234-2028-c20448218b4c
VERBOSE: 07/17/2023 12:03:34 Invoke-VMScript Finished execution
DEBUG: 07/17/2023 12:03:34 Invoke-VMScript
[91mInvoke-VMScript: [0m/polyglot/function/handler.ps1:50
[96mLine |
[96m 50 | [0m … nscriptsq = [96mInvoke-VMScript -VM $vm -ScriptText $scriptsq1 -GuestUser[0m …
[96m | [91m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[91m[96m | [91m07/17/2023 12:03:35 Invoke-VMScript A general system error occurred: vix error codes = (3033, 0).
[0m
Finished running action code.
Exiting powershell process.
Powershell process exited.
Can someone help?
VIX error code 3033 normally means "The guest does not support empty passwords"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for your response. But i am entering the password from the secrets as vcpassword variable, correct? any idea why i am still getting this?
I suspect this more of a vRA issue than a PowerCLI issue.
And I'm afraid I can't help you with anything vRA.
Shall I move your question to the vRA community?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, LucD. Let's see if someone from vRA community can help me on this.
Thank you for your amazing support 😄
Regards,
Lakshman
This definitely ooks like a working script with all of the comments in there. Were you able to get the output to show up in the local c:\temp folder in one of your tests? I"m assuming we're looking at the output in vRA here? And this an ABX action, right?
This is one that is hard to see at a glance, but these are some thing I may try in your siutation:
I don't use ABX actions myself (vRO + PS Host for us), so I'm not familar with any intricacies for getting them to work, so I don't have any specific vRA troubleshooting advice. But maybe running through the above steps can more definitively point to vRA as the problem.