powershell - getting an attribute value using other attribute value
-
Monday, February 18, 2013 8:35 PM
I have a command which can retrieve the objectid using an attribute1. How can I retrieve attribute2 using attribute1?
Thanks!
All Replies
-
Monday, February 18, 2013 9:06 PM
This is tricky question :) as we don't know what command you have in mind. I will assume that you are using standard powershell for FIM. I would advise you to use FIM libraries available on the Codeplex like this one for example:
http://fimpowershellmodule.codeplex.com/
And get some interest in - Convert-FimExportToPSObject and this http://fim.codeplex.com/wikipage?title=PSModule and see Get-FIMResource.
It should be pretty straightforward in this way ;)
Tomek Onyszko, memberOf Predica FIM Team (http://www.predica.pl), IdAM knowledge provider @ http://blog.predica.pl
- Marked As Answer by fim_sc Wednesday, March 13, 2013 2:24 PM
-
Monday, February 18, 2013 9:15 PM
Tomasz,
Thanks! Let's say
a)I have the employee id of a person object and I want to get the department(string) of the person.
b)Other scenario is , department is stored as reference.
I used the following to get objectid of the person. I read the psmodule and I am not sure what exactly I have to use to get the value of an attribute in my case.
get-fimobjectid -objectType Person -attributeName EmployeeID -AttributeValue $sponsorship.EMPID
-
Monday, February 18, 2013 10:59 PM
For (A) Something like this:
Get-FIMResource "/Person[EmployeeId='12345'] | $_.Department
for (b) - depends what you want to get - assuming that some deparment attribute based on person value of department and department is ref on an object type of Department
Get-FIMResource "/Department[ObjectId=/Person[EmployeeId='1234']/DepartmentRef] | $_.DerpartmentDisplayName
it is late and I'm writing it out of top of my head but it should work ;)
Tomek Onyszko, memberOf Predica FIM Team (http://www.predica.pl), IdAM knowledge provider @ http://blog.predica.pl
- Marked As Answer by Markus VilcinskasMicrosoft Employee, Owner Wednesday, March 13, 2013 11:46 AM
-
Tuesday, February 19, 2013 1:51 PM
You can use the following script
you can tweak the attributes to get any reference variable and its attribute
$ObjectType= "Person" $AttributeToSearch = "EmployeeID" $AttributeValue = "1002" $RefAttributeToSearch = "Manager" $RefAttribute = "DisplayName" $RefAttributeValue = ((Export-FIMConfig -onlybaseresources -customConfig "/$ObjectType[$AttributeToSearch='$AttributeValue']/$RefAttributeToSearch").ResourceManagementObject.ResourceManagementAttributes | Where-Object {$_.AttributeName -eq $RefAttribute}).ValueThis can also be used to traverse multiple references for example if you want the employee's manager's manager use
$RefAttributeToSearch = "Manager/Manager"
Regards Furqan Asghar
- Edited by Furqan Asghar Tuesday, February 19, 2013 1:58 PM Added the $RefAttributeValue variable
- Edited by Furqan Asghar Tuesday, February 19, 2013 2:05 PM
- Marked As Answer by Markus VilcinskasMicrosoft Employee, Owner Wednesday, March 13, 2013 11:45 AM

