I am using Powershell to generate a report using show-listview but sometimes when the user clicks the excel report or navigation button in the result window it's showing a runtime error.

I have verified the logs:

ManagedPoolThread #6 10:03:03 INFO The script execution in ScriptSession '$scriptSession$|p5tximzzm0ag34m2wvixqfvz|276a0a8b-f56f-46ec-bc78-46d60f1385c4' completed in 845 ms.
5360 10:03:04 INFO 'GET/handle' called by user: ''
96 10:03:32 INFO Executing PsSitecoreItemProvider.Start(providerInfo='Sitecore')     
96 10:03:32 INFO Executing PsSitecoreItemProvider.Start(providerInfo='Sitecore') 

I have tried with different browsers and private windows but still, I am getting the error. I have verified the user role - it has the permission

Any suggestion to avoid the error. Thanks!!

the below is the code I am using

function Get-ItemUrl($website,$itemToProcess,$itemLng){
     $site = [Sitecore.Sites.SiteContext]::GetSite($website)
        $urlOptions = [Sitecore.Links.LinkManager]::GetDefaultUrlOptions()
        $urlOptions.Language = $itemLng
        $url = [Sitecore.Links.LinkManager]::GetItemUrl($itemToProcess, $urlOptions)
        return "http"+$url
$options = @{
$props = @{
    Parameters = @(
        @{Name="selectedOption"; Title="Select the Site"; Options=$options;}
$selectedSite = Read-Variable @props
$PageBaseTemplateItem= "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}";
$pathNode = 'master://sitecore/content/Home
        $homeItem = Get-Item -Path $pathNode -Language *
        $allItems += $homeItem
        $allItems += Get-ChildItem -Path $pathNode -Recurse -Language * | Where-Object { $PageBaseTemplateItem -in $_.Template.BaseTemplates.ID}
$allItems  | Show-ListView -Property `
   @{ Name="Name"; Expression={$_.Name}},   
   @{ Name="Path"; Expression={$_.FullPath}},   
   @{ Name="URL"; Expression={Get-ItemURL -website $selectedOption -itemToProcess $_ -itemLng $_.Language}}

I am getting the below error msg:

[NullReferenceException: Object reference not set to an instance of an object.]
   Cognifide.PowerShell.Client.Controls.PowerShellListView.get_FilteredItems() +1137
   Cognifide.PowerShell.Client.Applications.PowerShellResultViewerList.SetVariables(ScriptSession session, Message message) +112
   Cognifide.PowerShell.Client.Applications.PowerShellResultViewerList.ExecuteScriptJob(Item scriptItem, ScriptSession scriptSession, Message message, Boolean autoDispose) +249
   Cognifide.PowerShell.Client.Applications.PowerShellResultViewerList.ExportResults(Message message) +345
   Cognifide.PowerShell.Client.Applications.PowerShellResultViewerList.HandleMessage(Message message) +1352
   Sitecore.Shell.Framework.Commands.MessageCommand.Execute(CommandContext context) +152
   Sitecore.Web.UI.Sheer.ClientPage.OnPreRender(EventArgs e) +547
   System.Web.UI.Control.PreRenderRecursiveInternal() +113
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4297
  • What versions are you running? – Michael West Apr 23 at 14:53
  • You might want to add information about the error (and if possible about the script). And "sometimes" always sounds fishy.. - any logic or just random? – Gatogordo Apr 23 at 14:54
  • I am using Sitecore Powershell module 5.0 – Karthik Apr 23 at 15:50
  • Hi Michael - I using Powershell module 5.0 – Karthik Apr 23 at 17:10
  • Hi Gatogordo, I have placed my code with the question – Karthik Apr 23 at 17:11

Your Answer

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

Browse other questions tagged or ask your own question.