Hello Luc,
thanks for your help, I have just tested your fonction and got same result, but as there is a "but"
I have seens that, the function was able to connect to the VM create both output file ( empty ) and .ps1 file ( empty also ).
Below the result :
VERBOSE: 25/04/2023 08:05:58 Get-View Finished execution
VERBOSE: 25/04/2023 08:05:58 Get-View Finished execution
VERBOSE: 25/04/2023 08:05:58 Get-View Finished execution
VERBOSE: 25/04/2023 08:05:59 Get-View Finished execution
VERBOSE: No GuestOSType value provided. Trying to determine now.
VERBOSE: It's a Windows guest OS
VERBOSE: Created temp folder in guest OS C:\Users\Deploy\AppData\Local\Temp\myAccount_1460vmware100
VERBOSE: Created temp script file in guest OS C:\Users\Deploy\AppData\Local\Temp\myAccount_1460vmware100\myAccount_1460vmware31.ps1
VERBOSE: Created temp output file in guest OS C:\Users\Deploy\AppData\Local\Temp\myAccount_1460vmware100\myAccount_1460_outputvmware69
VERBOSE: Copying Data to C:\Users\Deploy\AppData\Local\Temp\myAccount_1460vmware100\myAccount_1460vmware31.ps1
VERBOSE: HTTP/1.1 PUT with 11-byte payload
Invoke-WebRequest: C:\Users\myAccount\Documents\tst\Scripts\Invoke-VMScriptPlus.ps1:223
Line |
223 | … copyResult = Invoke-WebRequest -Uri $fileInfo -Method Put -Body $Data
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Aucune connexion n’a pu être établie car l’ordinateur cible l’a expressément refusée.
Exception: C:\Users\myAccount\Documents\tst\Scripts\Invoke-VMScriptPlus.ps1:226
Line |
226 | … Throw "ScripText copy failed!`rStatus $($copyResult.Statu …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| ScripText copy failed!Status
And I saw also that when I was testing the invoke-VMscript function in this way :
Invoke-VMScript -ScriptType Powershell -scriptText "New-Item -ItemType Directory -Path 'C:\Test'" -VM tstW2019 -GuestUser Administrateur -GuestPassword "ThePass" -Verbose
The folder was created, but the function was returning the error anyway.
So, in both case the function was able to connect to the VM, then do something on the VM and then got an error.
Any idea ?