2

I am using below Powershell command to read CSV file from directory:

$importData = Import-CSV "C:\Projects\news_sample.csv"

It's working fine on my local Sitecore instance and machine. I am running the same script on Azure CM instance and it's not working and throwing the error Directory not found.

Can anyone please let me know, how can I get the server path, I have put the CSV files on the Server using Filezilla but not able to determine the server path? Is there any Powershell command the same as Server.MapPath("~path") in C#?

Thanks.

2

In PowerShell you can use the Sitecore.IO.FileUtil.MapPath method to get your path:

$folder = [Sitecore.IO.FileUtil]::MapPath("~/path")
$importData = Import-CSV "$($folder)/news_sample.csv"
| improve this answer | |

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.