I have a folder on a net share - call it \Server\Backup\November.25.2013.backup. This folder has the sub folders \test1, \test2, \test3.
Example:
\\Server\Backup\November.25.2013.backup\
.\Test1
.\Test2
.\Test3
I need to copy the sub folders of November.25.2013.backup to c:\Test. This function is only to copy the backup folder contents of a specified day (in this case yesterday's backup). I am using this script to restore the last day's backup minus the name (November.25.2013.backup). Here is what I have been trying to utilize:
Get-ChildItem -Path \\Server\Backup -r | Where-Object {$_.LastWriteTime -gt (Get-Date).Date}
% { Copy-Item -Path $_.FullName -Destination C:\Test -WhatIf }
However I get the error
Copy-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:3 char:20
+ % { Copy-Item -Path <<<< $_.fullname -destination C:\Test -whatif }
+ CategoryInfo : InvalidData: (:) [Copy-Item], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.CopyItemCommand
Please understand that I am still a greenhorn with Powershell scripting and I am not sure how to troubleshoot this. I appreciate any advice.
My goal is to restore folders from a backup folder. Thanks.
|
(pipe) between the two statements. The%
(foreach) has no input. – Eris