1

This is working fine

$global:ProductPath = "/sitecore/content/Home/Content_Pages/ "
$csv = Import-CSV "C:\inetpub\wwwroot\mysample\Book1.csv"
$bulk = New-Object "Sitecore.Data.BulkUpdateContext"
try 
{
}

but if I direct it to media library like this

$csv = "/sitecore/media library/Documents/Book1.csv"

or

$csv = "/sitecore/media library/Documents/Book1"

It is not reading the records from the file.

What should I add, to make my script reading the content from media library folder?

4
# get media item
$media = Get-Item -Path "/sitecore/media library/Default Website/FL_insurance_sample"
# get stream and save content to variable $content
[System.IO.Stream]$body = $media.Fields["Blob"].GetBlobStream()
try    
{
    $contents = New-Object byte[] $body.Length
    $body.Read($contents, 0, $body.Length) | Out-Null
} 
finally 
{
    $body.Close()    
}

# convert to dynamic object
$csv = [System.Text.Encoding]::Default.GetString($contents) | ConvertFrom-Csv -Delimiter ","
$csv

source: Sitecore Content Import with Powershell

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.