5 Minute FIM Hacks: Find the right XPATH syntax to use in FIM PowerShell scripts or advanced set/group definitions

Published 11-01-2019 12:18 PM 109 Views
Microsoft

First published on MSDN on Oct 23, 2014

I recently had a colleague ask me to come with XPATH filter that he was using for PowerShell script to capture all users that did not have a specific attribute populated. I often seem to forget nuances of XPATH queries, such as should I be using something like a '!=' or '<>' to denote not present. Something I use now when dealing with XPATH is go to a group/set definition in the portal and try to put in the proper criteria for what I want and then submit it, then use advanced view to look at Filter attribute, this will show my XPATH. So this is the criteria as it looks in the UI:

 

 

 

 

This is advanced view of same set, which exposes XPATH query to use for string attribute not being populated:

 

 

So the XPATH that I want is
/Person[not(starts-with(AccountName, '%'))]

 

This is a different set definition, which looks for users which are a member for a specific group:

 

 

 

 

 

 

 

 

 

## http://blogs.msdn.com/connector_space ##

%3CLINGO-SUB%20id%3D%22lingo-sub-972574%22%20slang%3D%22en-US%22%3E5%20Minute%20FIM%20Hacks%3A%20Find%20the%20right%20XPATH%20syntax%20to%20use%20in%20FIM%20PowerShell%20scripts%20or%20advanced%20set%2Fgroup%20definitions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-972574%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Oct%2023%2C%202014%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EI%20recently%20had%20a%20colleague%20ask%20me%20to%20come%20with%20XPATH%20filter%20that%20he%20was%20using%20for%20PowerShell%20script%20to%20capture%20all%20users%20that%20did%20not%20have%20a%20specific%20attribute%20populated.%20I%20often%20seem%20to%20forget%20nuances%20of%20XPATH%20queries%2C%20such%20as%20should%20I%20be%20using%20something%20like%20a%20'!%3D'%20or%20'%26lt%3B%26gt%3B'%20to%20denote%20not%20present.%20Something%20I%20use%20now%20when%20dealing%20with%20XPATH%20is%20go%20to%20a%20group%2Fset%20definition%20in%20the%20portal%20and%20try%20to%20put%20in%20the%20proper%20criteria%20for%20what%20I%20want%20and%20then%20submit%20it%2C%20then%20use%20advanced%20view%20to%20look%20at%20Filter%20attribute%2C%20this%20will%20show%20my%20XPATH.%20So%20this%20is%20the%20criteria%20as%20it%20looks%20in%20the%20UI%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20542px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152835i1DC64A4226634AE9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20advanced%20view%20of%20same%20set%2C%20which%20exposes%20XPATH%20query%20to%20use%20for%20string%20attribute%20not%20being%20populated%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20541px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152836iEAED20E6809CDEA9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%20the%20XPATH%20that%20I%20want%20is%20%3CBR%20%2F%3E%3CSPAN%20style%3D%22font-size%3A%20small%3B%22%3E%20%3CSTRONG%3E%20%2FPerson%5Bnot(starts-with(AccountName%2C%20'%25'))%5D%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20a%20different%20set%20definition%2C%20which%20looks%20for%20users%20which%20are%20a%20member%20for%20a%20specific%20group%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20541px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152837i2BA14FA4BC423122%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20541px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F152838iADFB0ECFC1866DBF%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%23%23%20%3CA%20href%3D%22http%3A%2F%2Fblogs.msdn.com%2Fconnector_space%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20http%3A%2F%2Fblogs.msdn.com%2Fconnector_space%20%3C%2FA%3E%20%23%23%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-972574%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20MSDN%20on%20Oct%2023%2C%202014%20I%20recently%20had%20a%20colleague%20ask%20me%20to%20come%20with%20XPATH%20filter%20that%20he%20was%20using%20for%20PowerShell%20script%20to%20capture%20all%20users%20that%20did%20not%20have%20a%20specific%20attribute%20populated.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-972574%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EJoeZinn%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Feb 20 2020 12:24 PM
Updated by: