MethodInvocationException,Set-SFTPContent
Executed this cmd:
Set-SFTPContent -SFTPSession $ThisSession -Path "C:/Users/satya/satya.txt" -Value "testData"
the file does not exist in the dir "C:/Users/satya/". It has to create a new file with the name "satya.txt" . Getting below exception though file gets created at the specified dir.
Set-SFTPContent : Failed to write content to file C:/Users/satya/satya.txt
At line:1 char:1
+ Set-SFTPContent -SFTPSession $ThisSession -Path "C:/Users/satya/sat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], MethodInvocatio
nException
+ FullyQualifiedErrorId : System.Management.Automation.MethodInvocationExc
eption,Set-SFTPContent
Did you create the file first with new-sftpitem?
Did you create the file first with new-sftpitem?
No, but how the file gets created in the same specified dir ?
It does a writeall if not appended. Dont know how renci.ssh handles it in the library. It is raising a file not found error. Why does it raise the error and still create the file I dont know. Will add code to check for the file first and if -force is use create it sometime this week or next
Sent from my iPhone
On Feb 17, 2021, at 8:22 AM, Satya318 [email protected] wrote: Did you create the file first with new-sftpitem? No, but how the file gets created in the same specified dir ?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
Found the culprit .
Get-SFTPLocation -SFTPSession $ThisSession
O/P : /C:/Users/satya
why it returns one extra slash before C: even it is a windows machine.
I was trying with -Path "C:/Users/satya"