Answered by:
Get custom attributes from powershell

Question
-
I am trying to get a list of my windows computers in a specific group from powershell, for use in my documentationsystem
i can use get-agent - but the twist is that i need some attributes (AssetID and ServerLocation) in the output.
i made a new class that inherits from windows computer.
Boris made a script to list the groups a server was in, but i need it the other way around, with the extra attributes.
http://blogs.msdn.com/boris_yanushpolsky/archive/2007/10/26/which-groups-is-a-particular-computer-member-of.aspx
How can i get this information?
Thanks, MikeWednesday, January 27, 2010 3:54 PM
Answers
-
I am trying to get a list of my windows computers in a specific group from powershell, for use in my documentationsystem
i can use get-agent - but the twist is that i need some attributes (AssetID and ServerLocation) in the output.
i made a new class that inherits from windows computer.
Boris made a script to list the groups a server was in, but i need it the other way around, with the extra attributes.
http://blogs.msdn.com/boris_yanushpolsky/archive/2007/10/26/which-groups-is-a-particular-computer-member-of.aspx
How can i get this information?
Thanks, Mike
Was your question answered? Does this help?
HTH, Jonathan Almquist - MSFT- Proposed as answer by Jonathan Almquist Thursday, March 11, 2010 7:53 AM
- Marked as answer by Jonathan Almquist Tuesday, March 16, 2010 7:29 AM
Wednesday, March 10, 2010 1:14 AM
All replies
-
Maybe this can help?
http://blogs.technet.com/jonathanalmquist/archive/2009/12/01/groups-and-related-information.aspx
HTH, Jonathan Almquist - MSFTFriday, January 29, 2010 3:31 AM -
It helps me a bit, but im still stuck with how to get the custom attributes.
i can see the right hosts in the group, but i really cant figure out what the fields are called, displayname and such that are inherrited from windows computer works great, but my custom dosnt show.Friday, January 29, 2010 10:07 AM -
I got a tip about doing it like this:
$class = get-monitoringclass | where {$_.displayname -eq 'MyCustomClass}
$object = $class | get-monitoringobject | where {$_.displayname -eq 'myservername'}
$object | get-monitoringobjectproperty
$MS = $object | get-monitoringobjectproperty | where {$_.displayname -eq 'MyCustomAttribute'}
$MS.valueThe code used was found on http://relatedterms.com/ViewThread.aspx?t=1567730
I now just need to figure out how i can make a list of servers in a group with displayname and asset in a table, but that should be straight forward :)Friday, January 29, 2010 12:02 PM -
Michael,
How are you discovering these extended attributes/properties in this extended class? Via WMI, registry or script?
If I'm reading you correctly, you're trying to create some document that lists Agent computer names, along with a some discovered inventory?
HTH, Jonathan Almquist - MSFTFriday, January 29, 2010 8:43 PM -
I am trying to get a list of my windows computers in a specific group from powershell, for use in my documentationsystem
i can use get-agent - but the twist is that i need some attributes (AssetID and ServerLocation) in the output.
i made a new class that inherits from windows computer.
Boris made a script to list the groups a server was in, but i need it the other way around, with the extra attributes.
http://blogs.msdn.com/boris_yanushpolsky/archive/2007/10/26/which-groups-is-a-particular-computer-member-of.aspx
How can i get this information?
Thanks, Mike
Was your question answered? Does this help?
HTH, Jonathan Almquist - MSFT- Proposed as answer by Jonathan Almquist Thursday, March 11, 2010 7:53 AM
- Marked as answer by Jonathan Almquist Tuesday, March 16, 2010 7:29 AM
Wednesday, March 10, 2010 1:14 AM -
Hi Jonathan,
thanks for the link.
It looks promising, i havent looked into it yet, give me a couple of days and i will paste my complete script so far, mostly for future referencing.Wednesday, March 17, 2010 10:12 AM -
Hi, sorry to bring this topic from the dead. I've been trying to filter a list by an object's extended properties but I can't seem to be able to. If I list the object with:
Get-SCOMClass -Name 'My.Extended.Class' | Get-SCOMClassInstance | fl
I can see things like:
HasChanges
Id
ManagementGroupId[Microsoft.Windows.Server.Computer].IsVirtualNode
[Microsoft.Windows.Computer].PrincipalName
[Microsoft.Windows.Computer].DNSName
[Microsoft.Windows.Computer].NetbiosComputerName
[Microsoft.Windows.Computer].NetbiosDomainName
[Microsoft.Windows.Computer].IPAddress
[Microsoft.Windows.Computer].NetworkName
[Microsoft.Windows.Computer].ActiveDirectoryObjectSid
[Microsoft.Windows.Computer].IsVirtualMachine
[Microsoft.Windows.Computer].DomainDnsName
[Microsoft.Windows.Computer].OrganizationalUnit
[Microsoft.Windows.Computer].ForestDnsName
[Microsoft.Windows.Computer].ActiveDirectorySite
[Microsoft.Windows.Computer].LogicalProcessors
[Microsoft.Windows.Computer].PhysicalProcessors
[Microsoft.Windows.Computer].HostServerNamebut if I try to filter (using ft or select) by any of the field in brackets [], I shows just empty space.
I've tried attributing one object to a variable and I can even tab to the properties between brackets, but if I try to show it, I get:
PS C:\> $agent.[Microsoft.Windows.Computer].ActiveDirectoryObjectSid
Unable to find type [Microsoft.Windows.Computer]: make sure that the assembly containing this type is loaded.
At line:1 char:36
+ $agent.[Microsoft.Windows.Computer] <<<< .ActiveDirectoryObjectSid
+ CategoryInfo : InvalidOperation: (Microsoft.Windows.Computer:String) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFoundAny ideas?
Thank you,
Jose Fehse
MCITP, MCSE, MCTS
- Proposed as answer by Alexis Yakovlev Wednesday, November 20, 2013 3:39 PM
- Unproposed as answer by Alexis Yakovlev Wednesday, November 20, 2013 3:39 PM
Wednesday, January 9, 2013 8:31 PM -
Hi,
$agent.'[Microsoft.Windows.Computer].ActiveDirectoryObjectSid'
Wednesday, November 20, 2013 3:48 PM