I currently have a script that puts a file in a directory the website but would rather create it in the Data directory.

The powershell script has the below:

$FilePath = $AppPath + "Temp_files\MyLists\"

Current Result, file into directory "D:/inetpub/mysite.com/Website/Temp_files/MyLists/"

Preferred Result, file into directory: "D:/inetpub/mysite.com/Data/Temp_files/MyLists/"

Any assistance is appreciated.

  • Are you expecting the script to run from within the context of Sitecore or are you running this directly in the instance of Windows? Oct 4, 2017 at 21:12

2 Answers 2


I assume your question is requesting how to do this using Sitecore PowerShell Extensions.

There are a number of builtin variables that SPE generates. I recommend you make use of those before using the static variables with a fully-qualified namespace.

Example: The following uses the variable $SitecoreDataFolder.

$filepath = "$($SitecoreDataFolder)\Temp_Files\MyLists"


List of variables

  • Correct on the Sitecore PowerShell Extensions. Thanks for the answer and the link to the Reference.
    – DanO
    Oct 5, 2017 at 17:04

You can try in this way:

 $dataFolder = [Sitecore.Configuration.Settings]::DataFolder
 $tempFolder = $dataFolder + "\Temp_files\MyLists\"
  • Thx, I added a "\" in front of the "Temp_files\MyLists\" so it needs to be "\Temp_files\MyLists\"
    – DanO
    Oct 4, 2017 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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