Hi Experts,
Am trying to copy multiple files in the $finalfile variable but receiving the error '@{FullName = D' doesnot exist'
The script is working well apart from the For Each copy part. Please suggest
function Wait-UdfFileCreation { [CmdletBinding()] param ( [string] $path, # Folder to be monitored [string] $file # File name pattern to wait for. ) $theFile = $path + $file $finalfile = Get-ChildItem -Path $theFile | Where-Object length -GT (17000000) | Select-Object -Property FullName While ($true) { IF ( $finalfile -ne $null ) { #file exists. break loop break } Start-Sleep -s 15 } foreach ($file in $finalfile) { Copy-Item $file -Destination "D:\FileLocation\Processing\" } Write-Verbose 'File found.' } $rootfolder = "D:\FileLocation\" $ftppath ="File*.txt" Wait-UdfFileCreation $rootfolder $ftppath -Verbose