locked
propertyName exception and error in PS script RRS feed

  • Question

  • Hello

    Thank you for this KA.
    But not everything is go as you wrote in article. After importing customized pack (the same class was customized as you describe) I tried to use it for service offering creation and saw exception "propertyName" like in this article.

    I did all step and have some another result as you showed:

    1. I got two different forms - I don't know why

    2. I got error on step "GetManagementPack() method"

    Could you help with this?

    Also it's interesting why this exception appears not for all customized classes ?

    Thank you


    • Edited by Dmytro S Wednesday, July 4, 2012 3:27 PM
    Wednesday, July 4, 2012 1:36 PM

Answers

  • Try next:

    param([string]$className, [switch]$ReturnTarget)
    
    $cl = Get-SCSMClass -Name "$className$"
    $allIds = @{$cl.Id=$cl} 
    $tps = Get-SCSMTypeProjection | ? {$_.TargetType -eq $cl} | % { $allIds.Add($_.Id, $_)} 
    $form = Get-SCSMForm | ? { $allIds.Keys -contains $_.Target.Id}
    
    if($ReturnTarget)
    {
        $form | % {$allIds[$_.Target.Id]}
    }
    else
    {    
    return $form
    } 


    http://www.scsmsolutions.com/ freemanru (at) gmail (dot) com

    • Marked as answer by Dmytro S Friday, July 6, 2012 9:14 AM
    Wednesday, July 4, 2012 3:58 PM

All replies

  • 1. It's really intresting. Can you run next code:

    .\Get-SCSMFormByClassName.ps1 "System.WorkItem.ServiceRequest" | % {Get-SCSMClass -Id $_.Target.Id | select Name} 
    
    .\Get-SCSMFormByClassName.ps1 "System.WorkItem.ServiceRequest" | % {Get-SCSMTypeProjection -Id $_.Target.Id | select Name}


    http://www.scsmsolutions.com/ freemanru (at) gmail (dot) com

    Wednesday, July 4, 2012 3:23 PM
  • Ready. Here  is answers:

    What to do with this next ?

    Wednesday, July 4, 2012 3:33 PM
  • Try next:

    param([string]$className, [switch]$ReturnTarget)
    
    $cl = Get-SCSMClass -Name "$className$"
    $allIds = @{$cl.Id=$cl} 
    $tps = Get-SCSMTypeProjection | ? {$_.TargetType -eq $cl} | % { $allIds.Add($_.Id, $_)} 
    $form = Get-SCSMForm | ? { $allIds.Keys -contains $_.Target.Id}
    
    if($ReturnTarget)
    {
        $form | % {$allIds[$_.Target.Id]}
    }
    else
    {    
    return $form
    } 


    http://www.scsmsolutions.com/ freemanru (at) gmail (dot) com

    • Marked as answer by Dmytro S Friday, July 6, 2012 9:14 AM
    Wednesday, July 4, 2012 3:58 PM
  • Error:

    Index operation failed; the array index evaluated to null.
    At C:\Infopulse-SCSM\getscsmtypeprojection.ps1:4 char:13
    + $allIds = @{ <<<< $cl.Id=$cl}
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : NullArrayIndex

    Wednesday, July 4, 2012 4:11 PM
  • How did you run that script? Did you set class name after the script?


    http://www.scsmsolutions.com/ freemanru (at) gmail (dot) com

    Wednesday, July 4, 2012 4:22 PM
  • Result with class name:

    Wednesday, July 4, 2012 5:39 PM
  • That's all. Now it must working, and GetManagementPack() too.

    http://www.scsmsolutions.com/ freemanru (at) gmail (dot) com

    Wednesday, July 4, 2012 7:30 PM
  • Why do I have two items the result on screenshot?

    Thursday, July 5, 2012 8:11 AM