Quantcast
Channel: SCSM PowerShell Cmdlets
Viewing all articles
Browse latest Browse all 306

New Post: issue using -filter switch on get-scsmobject

$
0
0
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.

Gets the MAobj

$MAobj = Get-SCSMObject -Class $MAClass -Filter "ID -eq $MAID"

Filters out the All Activites Q, (no other Qs exist)

$ParentCR = Get-SCSMRelationshipObject -ByTarget $MAobj | ? {$_.sourceobject.tostring() -ne "All Activities Queue"}

Gets the CR displayname from the source object in the relationship

[string]$CRdisplayname = $ParentCR.SourceObject.DisplayName

Attempts to pull the CR based on the above values.

$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.

Viewing all articles
Browse latest Browse all 306

Trending Articles