When you post code or error messages or sample data or console output format it as code, please.
In the “Text” view you can use the code tags “PRE”, in the “Visual” view you can use the format template “Preformatted”.
Thanks in advance.
That’s actually more a robocopy question than Powershell. robocopy takes as the source only a single folder path. You cannot provide an array. So if I got it right this should be enough:
In my source location I would like to filter on a specific folder (“BACKUP”) and copy that folder to the destination and not just the contents within the folder if that makes sense.
What do you mean with filter? If you know the name (path) of the folder just provide this name (path).
That does make sense and I already showed you above how to achieve this. You have to include the name of the folder in the destination path you provide for robocopy.
1 - Olaf showed you how to do it if you only have one back-up folder
2 - If you are expecting to get more than one folder returned, then you need to do a ForEach loop (ForEach ($Folder in $Source))
3 - Robocopy expects you to provide the full path, so you need to get the property “FullName” for the folder, so your first command could look like this:
Since i feel this is a bit related id like to see if you can review.
I cannot create a new thread waiting on the registration authorization. #waiting
ForEach ($system in (Get-Content C:\book1.txt)) {
# Retrieve a list of computers to connect to
$file = "\\$system\c$\CPI\Desktop\desktop.log"
#location of the file to retrieve
# Is the File there?
if ( Test-Path $file){
# Yup now make a copy of that file into local computer
copy "c:\CPI\Desktop\desktop.log" -Destination "\\my computer\c$\LETS\$system\"
}
}
`I believe the problem is on the copy #my intent is to copy from the $system ls to the -destination my local computer. on the if cmdlet can it pull the $system variable or does it “know” its within the $system ls/dir
When you post code or error messages or sample data or console output format it as code, please.
In the “Text” view you can use the code tags “PRE”, in the “Visual” view you can use the format template “Preformatted”. You can go back edit your post and fix the formatting - you don’t have to create a new one.
Thanks in advance.
You post probably is on hold for moderation. You probably editted too often in a short amount of time. The forum software (spam and malware detection) does not like that.