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?

# 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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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