The Value Supplied Is Not Valid
- sameer12
- Joined:
- Posts:
- half-dozen
- Location:
- Pakistan
Hello Experts !
I am new to Winscp and trying to get the latest files from ftp site only having errors,please see what i am doing incorrect a remote path or SshHostKeyFingerprint. I am attaching my remote path from winscp software.
New-Object : The value supplied is not valid, or the holding is read-only. Change the value
At line:1 char:29
+ $sessionOptions = New-Object <<<< WinSCP.SessionOptions -Property @{
+ CategoryInfo : InvalidData: (:) [New-Object], Exception
+ FullyQualifiedErrorId : InvalidValue,Microsoft.PowerShell.Commands.NewObjectCommand
Server & Protocol information
Remote system = Windows_NT File transfer protocol = FTP Cryptographic protocol = TLS/SSL Explicit encryption, TLSv1 Encryption algorithm = TLSv1/SSLv3: ECDHE-RSA-AES256-SHA, 2048 scrap RSA, ECDHE-RSA-AES256-SHA SSLv3 Kx=ECDH Au=RSA Enc=AES(256) Mac=SHA1 Compression = No ------------------------------------------------------------ Document fingerprint 5f:66:34:advertisement:e9:a9:8f:c2:60:79:d8:38:f6:da:7a:0b:68:d7:94:3C ------------------------------------------------------------ Can modify permissions = Yep Can change owner/grouping = No Can execute arbitrary command = Protocol commands only Can create symbolic/hard link = No/No Tin can lookup user groups = No Can duplicate remote files = No Can check available space = No Can calculate file checksum = No Native text (ASCII) fashion transfers = No ------------------------------------------------------------ Additional information The server supports these FTP boosted features: LANG EN* UTF8 AUTH TLS;TLS-C;SSL;TLS-P; PBSZ PROT C;P; CCC HOST SIZE MDTM REST STREAM
# Load WinSCP .NET assembly Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll" # Set upwards session options $sessionOptions = New-Object WinSCP.SessionOptions -Holding @{ # Protocol = [WinSCP.Protocol]::Sftp Protocol = [WinSCP.Protocol]::ftp HostName = "10.162.12.fifteen" UserName = "Administrator" Password = "Admin" SshHostKeyFingerprint = "ssh-rsa 1024 5f:66:34:ad:e9:a9:8f:c2:60:79:d8:38:f6:da:7a:0b:68:d7:94:3C" } $session = New-Object WinSCP.Session attempt { # Connect $session.Open($sessionOptions) # Transfer files $sourcePath = "/*.*" $destPath = "D:\ReplicationViaFTPServer\" $destPathNew = "D:\FTP\Data\" $transferOptions = New-Object WinSCP.TransferOptions $transferOptions.FileMask = "*PAT*.*;*Sch*.*|*Total*.*" while ($True) { try { $synchronizationResult = $session.SynchronizeDirectories( [WinSCP.SynchronizationMode]::Local, $destPath, $sourcePath, $False, $transferOptions) $synchronizationResult.Check() Write-Host "Synchronization on folder $($destPath) succeeded!" } catch { Write-Host "Exception catched while synchronizing the folder $($destPath)" } finally { foreach ($transfer in $synchronizationResult.Transfers) { try { Copy-Particular Get-Content( $destPath + $transfer.FileName) -Destination Become-Content( $destPathNew + $transfer.FileName) -Force Write-Host "Copy of file $($transfer.FileName) succeeded" } catch { Write-Host "Exception catched while copying the file $($transfer.FileName)" } } } } Write-Host "Waiting..." Kickoff-Sleep -Seconds 5 } finally { $session.Dispose() } Reply with quote
Advertizement
- martin◆
Site Admin -
- Joined:
- Posts:
- 36,947
- Location:
- Prague, Czechia
SessionOptions.SshHostKeyFingerprint cannot be set, when the protocol is FTP.
Reply with quote
- sameer12
- Joined:
- Posts:
- 6
- Location:
- Pakistan
Thanks Admin Martin
Now the errors
The value supplied is not valid, or the property is read-only. Change the value
get abroad finding another error
Exception catched while synchronizing the binder D:\ReplicationViaFTPServer\
Answer with quote
- martin◆
Site Admin -
- Joined:
- Posts:
- 36,947
- Location:
- Prague, Czechia
That's your error, information technology does non say anything to u.s..
Delight adhere a full session log file showing the problem (using the latest version of WinSCP).
To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an zipper. Note that passwords and passphrases not stored in the log. Y'all may want to remove other data y'all consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you exercise non want to post the log publicly, you can marker the attachment every bit private.
Reply with quote
- sameer12
- Joined:
- Posts:
- 6
- Location:
- Pakistan
HI Admin Martin,
Go along tried i am able to download the files successfully . The below lawmaking works for me, only the event i am facing while running the script from windows ability shell. The windows does not close after entering the log to sessionlog.log (file). Proceed writing same information to session. In the picture fastened i have just 3 files for testing purpose ,but the it keep writing the duplicates to sessionlog.log. I want to stop writing duplication shut Windows power shell subsequently completing the downloads from FTP. Delight assist me out.
# Load WinSCP .NET assembly Add-Type -Path "C:\Plan Files (x86)\WinSCP\WinSCPnet.dll" # Set up session options # Load WinSCP .Cyberspace assembly Add-Type -Path "WinSCPnet.dll" # Fix upwards session options $sessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::Ftp HostName = "*****" PortNumber = 21 UserName = "*******" Countersign = "******" FtpSecure = [WinSCP.FtpSecure]::Explicit TlsHostCertificateFingerprint = "5f:66:34:ad:e9:a9:8f:c2:60:79:d8:38:f6:da:7a:0b:68:d7:94:3b" } $session = New-Object WinSCP.Session $session.SessionLogPath = "D:\ReplicationViaFTPServer\LogBackups\Sessionlog.log" try { # Connect $session.Open up($sessionOptions) # Transfer files $remotePath = "D:\FTP\*" $sourcePath = "/*.*" $destPath = "D:\ReplicationViaFTPServer\*.*" $destPathNew = "D:\FTP\Caspio\" $transferOptions = New-Object WinSCP.TransferOptions $transferOptions.FileMask = "*PAT*.*;*.TRN;*Sch*.*|*Full*.*" while($True) { try { $transferResult = $session.GetFiles($sourcePath, $destPath, $False, $transferOptions) $transferResult.Bank check() } finally { foreach ($transfer in $transferResult.Transfers) { $session.GetFiles($transfer.FileName, $destPathNew, $False, $transferOptions) Write-Host "Download of $($transfer.FileName) succeeded" } $destPathNew1 } } Write-Host "Waiting..." Start-Sleep -Seconds five } finally { $session.Dispose() } Reply with quote
Advertisement
- martin◆
Site Admin -
- Joined:
- Posts:
- 36,947
- Location:
- Prague, Czechia
The windows does not close after inbound the log to sessionlog.log (file)
I'1000 not sure I understand.
The program/window does not close, equally you take an infinite loop there:
Reply with quote
- sameer12
Hi Martin !
Many Cheers .
Reply with quote
Advertising
Source: https://winscp.net/forum/viewtopic.php?t=27505
0 Response to "The Value Supplied Is Not Valid"
Enviar um comentário