4

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.

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

2 Answers 2

5

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"

Reference

List of variables

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

You can try in this way:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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