The value supplied is not valid, or the property is read-only. Change the value
Hi Martin !
Many Thanks.
Many Thanks.
The windows does not close after entering the log tosessionlog.log
(file)
while ($True)
sessionlog.log
. I want to stop writing duplication close Windows PowerShell after completing the downloads from FTP. Please help me out.
# Load WinSCP .NET assembly
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
# Load WinSCP .NET assembly
Add-Type -Path "WinSCPnet.dll"
# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Ftp
HostName = "*****"
PortNumber = 21
UserName = "*******"
Password = "******"
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($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.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 5
}
finally
{
$session.Dispose()
}
Session.SessionLogPath
. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.go away finding another errorThe value supplied is not valid, or the property is read-only. Change the value
Exception catched while synchronizing the folder D:\ReplicationViaFTPServer\
SessionOptions.SshHostKeyFingerprint
cannot be set, when the protocol is FTP.
SshHostKeyFingerprint
. I am attaching my remote path from WinSCP software.
New-Object : The value supplied is not valid, or the property 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
Remote system = Windows_NT
File transfer protocol = FTP
Cryptographic protocol = TLS/SSL Explicit encryption, TLSv1
Encryption algorithm = TLSv1/SSLv3: ECDHE-RSA-AES256-SHA, 2048 bit RSA, ECDHE-RSA-AES256-SHA SSLv3 Kx=ECDH Au=RSA Enc=AES(256) Mac=SHA1
Compression = No
------------------------------------------------------------
Certificate fingerprint
5f:66:34:ad:e9:a9:8f:c2:60:79:d8:38:f6:da:7a:0b:68:d7:94:3C
------------------------------------------------------------
Can change permissions = Yes
Can change owner/group = No
Can execute arbitrary command = Protocol commands only
Can create symbolic/hard link = No/No
Can lookup user groups = No
Can duplicate remote files = No
Can check available space = No
Can calculate file checksum = No
Native text (ASCII) mode transfers = No
------------------------------------------------------------
Additional information
The server supports these FTP additional 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 up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::ftp
HostName = "10.162.12.15"
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
try {
# Connect
$session.Open($sessionOptions)
# Transfer files
$sourcePath = "/*.*"
$destPath = "D:\ReplicationViaFTPServer\"
$destPathNew = "D:\FTP\Data\"
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "*PAT*.*;*Sch*.*|*Full*.*"
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-Item Get-Content( $destPath + $transfer.FileName) -Destination Get-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..."
Start-Sleep -Seconds 5
}
finally {
$session.Dispose()
}