I have an issue with access child files using Sitecore Powershell script
- I have created powershell script under
/sitecore/system/Modules/PowerShell/Script Library/Tasks
to copy files from a physical folderE:\FolderA\
to another folder under my siteE:\inetpub\wwwroot\site\upload\FolderA\
- The powershell script didn't return child files and return 0 files found.
- Note that if I save the script in any directory out from Sitecore and run it using powershell it works and copy all the data.
This is my script:
$sourcepath = "E:\FolderA\"
$targetpath = "E:\inetpub\wwwroot\site\upload\FolderA\"
"$(get-date -f yyyyMMdd-HHmmss) Getting files from source $sourcepath" |
out-file -filepath $logFile -append
#$allsourcefiles = get-childitem -path $sourcepath
#"$(get-date -f yyyyMMdd-HHmmss) Found " + $allsourcefiles.Count | out-file
-filepath $logFile -append
$initialDate = (Get-Date).AddDays(-1)
$endDate = (Get-Date).AddDays(1)
$allsourcefiles = get-childitem -path $sourcepath
"$(get-date -f yyyyMMdd-HHmmss) Total found " + $allsourcefiles.Count | out-
file -filepath $logFile -append