locked
Trouble Filtering on displayname using SMlets RRS feed

  • Question

  • Has anyone seen this before?

    Having trouble with this bit of code... the -filter is not working as I would expect.

    $MAID is set from the authoring tool

    Everything works up to the last line.

    $MAobj = Get-SCSMObject -Class $MAClass -Filter "ID -eq $MAID"
    $ParentCR = Get-SCSMRelationshipObject -ByTarget $MAobj | ? {$_.sourceobject.tostring() -ne "All Activities Queue"}
    [string]$CRdisplayname = $ParentCR.SourceObject.DisplayName
    $CRobj = Get-SCSMObject -Class $CRClass -Filter "Displayname -eq $CRdisplayname"

    Nothing is returned, no error... no results.

    But if I do this,

    Get-SCSMObject -Class $CRClass | ?{$_.displayname -eq "CR7554: Are we able to hide these in the Navigation Pane?"}

    I get the CR as expected. I can even do this,

    Get-SCSMObject -Class $CRClass | ?{$_.displayname -eq "$CRdisplayname?"}

    And it works as expected.

    Additionally, I have removed the extra Queue, and simplified the code, and still have the same issue...

    $MAobj = Get-SCSMObject -Class $MAClass -Filter "ID -eq $MAID"
    [string]$CRDisplayname = (Get-SCSMRelationshipObject -ByTarget $MAobj).sourceobject.displayname
    $CRobj = Get-SCSMObject -Class $CRClass -Filter "Displayname -eq $CRDisplayname"


    Joshua Fuente


    • Edited by NachoScript Friday, February 15, 2013 4:13 PM added info
    Friday, February 15, 2013 2:16 PM

All replies

  • BAH!!! I fixed it...

    $MAobj = Get-SCSMObject -Class $MAClass -Filter "ID -eq $MAID"
    [string]$CRID =  (Get-SCSMRelationshipObject -ByTarget $MAobj).sourceobject.name
    $CRobj = Get-SCSMObject -Class $CRClass -Filter "Id -eq $CRID"


    Joshua Fuente


    • Edited by NachoScript Friday, February 15, 2013 4:45 PM
    Friday, February 15, 2013 4:43 PM