i am having some windows backup folder and want to put it on some samba share folder to create a backups, problem is that in windows it creates every day backups, and i want only the latest. Files are named like: Backkup1.zip, Backkup2.zip, etc.
where is mistake? This copy all content, not only the newest one, and not only Backkup*.zip files, i put some txt and that copy also
In your last code line you’re using $backuppath. I think it should be $_.FullName instead. … and I think you should wrap this last command in a Foreach-Object scriptblock.
pscp for transfering files. Understand what you mean, if i want to catch a file to copy, then to work with files, not to use folder.
Can you help with that last part
I think the mistake in your script is although you have selected the latest backup file you are passing the folder path only and not the selected file path to pscp.
$backuppath still has D:Backups. So pscp is copying the all the contents from this folder(including .txt files or others as you have said) and that too recursively because you have -r argument as well (I think this is not required.)
this should work: pscp -pw mypass $_.FullName user@192.168.12.20:/mnt/DatabaseBackup