I'm new to PowerShell. Spent several days trying to get this, think I am very close, but need an expert to show me the final step.
Using PowerShell v5, Need to search for folder(s) which match specific name, then copy those folders and their files, AND the path to the Folders to another drive.
Script now:
Get-ChildItem s:\ -Filter (Read-Host -Prompt "Enter") -Recurse -ErrorAction SilentlyContinue -Force |
Select-Object FullName | ForEach-Object {Copy-Item -Path $_.FullName -Destination 'C:\Robotics\AA\ConfigFiles\Automation Anywhere Files\Automation Anywhere\My Tasks\' -recurse -Force}
This does a search for the Folder, returns results and then copies the folder and contents into the destination location.
The problem is, I actually needed the source path appended to my destination path. Source is variable number of folders deep.
Any suggestions?
S:\
should be replaced withC:\Robotics\AA\ConfigFiles\Automation Anywhere Files\Automation Anywhere\My Tasks\
? Is there a reason to write this as a one liner? – user6811411