LucD
Hi thanks for response. I didn't modifying anything on the script I just copy it as is and run it.
So tried this version below and use the rm -rf command and it deletes the duplicate file with "?" but if I run it again original TMP still there.
$esxName = 'hostname'
$cred = Get-Credential -Message 'Enter credentials'
$cmdsub = @'
rm -rf /tmp/ams-bbUsg.txt
'@
$esx = Get-VMHost -Name $esxName
$session = New-SSHSession -ComputerName $esx.Name -Credential $cred –AcceptKey
$result = Invoke-SSHCommand -SSHSession $session -Command $cmdSub
Remove-SSHSession -SSHSession $session | Out-Null
Apologies, still learning the PowerShell hope you can help me.