<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article Get-CustomField.ps1 Script in VMware PowerCLI Documents</title>
    <link>https://communities.vmware.com/t5/VMware-PowerCLI-Documents/Get-CustomField-ps1-Script/ta-p/2779858</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="noformat"&gt;# TITLE: 	Get-CustomField.ps1
# AUTHOR:	Hal Rottenberg &amp;lt;hal@halr9000.com&amp;gt;
# PURPOSE:	Retrieve custom field data from any VMware Infrastructure "managed entity" 
# 			(i.e. VM, VMHost, Cluster, etc.).
# USAGE:	Use a Get cmdlet such as Get-VM or Get-Inventory and pipe to this script.
#			Optionally, specify the Name parameter to modify items retrieved.  Wildcards
#			are permitted.
# INPUT:	By pipeline only, any managed entity.
# OUTPUT:	A custom object containing the fields Name, Value, InputObject, and Type
# EXAMPLE:	
# PS&amp;gt; Get-Inventory | Get-CustomField.PS1 -name Service*
# 
# Name                    Value                  InputObject            Type
# ----                    -----                  -----------            ----
# ServiceLevel            Gold                   192.168.0.51           VMHostImpl

param (
	$Include # Search by this custom field name (aka key)
)
Process {
	# If the object on the pipeline does not have a CustomFields property, ignore it
	if ( !$_.CustomFields ) { continue }
	# Save this for later inclusion into the output custom object.
	$InputObject =  $_
	# An entity can be one of several types, it may be useful to know which one.
	$Type = $InputObject.GetType().Name
	$_.CustomFields | ForEach-Object {
		# If Name was provided, filter out the non-matches
		if ( ( $Name -and ( $_.Key -like $Name )) -or !$Name ) {
			# Build custom object to hold output.
			$Process = New-Object PSObject
			$Process | Add-Member -MemberType NoteProperty -Name Name -Value $_.Key -PassThru |
				Add-Member -MemberType NoteProperty -Name Value $_.Value -PassThru |
				Add-Member -MemberType NoteProperty -Name InputObject -Value $InputObject -PassThru |
				Add-Member -MemberType NoteProperty -Name Type -Value $Type
			Write-Output $Process
		}
	}
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 29 Jun 2008 21:15:50 GMT</pubDate>
    <dc:creator>halr9000</dc:creator>
    <dc:date>2008-06-29T21:15:50Z</dc:date>
    <item>
      <title>Get-CustomField.ps1 Script</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Documents/Get-CustomField-ps1-Script/ta-p/2779858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="noformat"&gt;# TITLE: 	Get-CustomField.ps1
# AUTHOR:	Hal Rottenberg &amp;lt;hal@halr9000.com&amp;gt;
# PURPOSE:	Retrieve custom field data from any VMware Infrastructure "managed entity" 
# 			(i.e. VM, VMHost, Cluster, etc.).
# USAGE:	Use a Get cmdlet such as Get-VM or Get-Inventory and pipe to this script.
#			Optionally, specify the Name parameter to modify items retrieved.  Wildcards
#			are permitted.
# INPUT:	By pipeline only, any managed entity.
# OUTPUT:	A custom object containing the fields Name, Value, InputObject, and Type
# EXAMPLE:	
# PS&amp;gt; Get-Inventory | Get-CustomField.PS1 -name Service*
# 
# Name                    Value                  InputObject            Type
# ----                    -----                  -----------            ----
# ServiceLevel            Gold                   192.168.0.51           VMHostImpl

param (
	$Include # Search by this custom field name (aka key)
)
Process {
	# If the object on the pipeline does not have a CustomFields property, ignore it
	if ( !$_.CustomFields ) { continue }
	# Save this for later inclusion into the output custom object.
	$InputObject =  $_
	# An entity can be one of several types, it may be useful to know which one.
	$Type = $InputObject.GetType().Name
	$_.CustomFields | ForEach-Object {
		# If Name was provided, filter out the non-matches
		if ( ( $Name -and ( $_.Key -like $Name )) -or !$Name ) {
			# Build custom object to hold output.
			$Process = New-Object PSObject
			$Process | Add-Member -MemberType NoteProperty -Name Name -Value $_.Key -PassThru |
				Add-Member -MemberType NoteProperty -Name Value $_.Value -PassThru |
				Add-Member -MemberType NoteProperty -Name InputObject -Value $InputObject -PassThru |
				Add-Member -MemberType NoteProperty -Name Type -Value $Type
			Write-Output $Process
		}
	}
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Jun 2008 21:15:50 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Documents/Get-CustomField-ps1-Script/ta-p/2779858</guid>
      <dc:creator>halr9000</dc:creator>
      <dc:date>2008-06-29T21:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Get-CustomField.ps1 Script</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Documents/Get-CustomField-ps1-Script/tac-p/2779859#M126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i cant seem to get this to filter by the name doesnt mater what i do it just sends every thing back.&lt;/P&gt;&lt;P&gt;Not a biggy as i can clean it up in excel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2009 02:50:01 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Documents/Get-CustomField-ps1-Script/tac-p/2779859#M126</guid>
      <dc:creator>Mllii</dc:creator>
      <dc:date>2009-02-05T02:50:01Z</dc:date>
    </item>
  </channel>
</rss>

