3

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 folder E:\FolderA\ to another folder under my site E:\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
4
  • 1
    Does the IIS App Pool identity that's running Sitecore have read access to the source directory? You may want to check access permissions on that source folder. Sep 27 '17 at 12:46
  • Thank you very much, it works after I add read access to app pool identity. Sep 27 '17 at 19:38
  • In the future please paste the gist as text rather than an image. Dec 18 '17 at 15:38
  • Thank you Michael for your comment, I removed the image and replaced it with the code :) Dec 21 '17 at 20:11
1

solved by add read access permissions to IIS App Pool identity that's running Sitecore and add read access permissions to have read access permissions on the source directory.

Not the answer you're looking for? Browse other questions tagged or ask your own question.