<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>check if vmtools is upto date powershell Archives - the Sysadmin Channel</title>
	<atom:link href="https://thesysadminchannel.com/tag/check-if-vmtools-is-upto-date-powershell/feed/" rel="self" type="application/rss+xml" />
	<link>https://thesysadminchannel.com/tag/check-if-vmtools-is-upto-date-powershell/</link>
	<description>Documenting My Life as a System Administrator</description>
	<lastBuildDate>Tue, 17 Nov 2020 22:41:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>
<site xmlns="com-wordpress:feed-additions:1">144174110</site>	<item>
		<title>Get VMInformation Using Powershell and PowerCLI</title>
		<link>https://thesysadminchannel.com/get-vminformation-using-powershell-and-powercli/</link>
					<comments>https://thesysadminchannel.com/get-vminformation-using-powershell-and-powercli/#comments</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Thu, 13 Jun 2019 03:59:53 +0000</pubDate>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[check if vmtools is upto date powershell]]></category>
		<category><![CDATA[Get-VMInformation]]></category>
		<category><![CDATA[Get-VMInformation Using Powershell and PowerCLI]]></category>
		<category><![CDATA[vm properties script]]></category>
		<category><![CDATA[vmware powercli examples]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=1741</guid>

					<description><![CDATA[<p>It&#8217;s always a good idea to get a high level overview of what&#8217;s going on with your VMware environment. When it comes to VMs, the command Get-VM, has a lot of useful information regarding your virtual machines. Today we&#8217;re going&#8230; <a href="https://thesysadminchannel.com/get-vminformation-using-powershell-and-powercli/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/get-vminformation-using-powershell-and-powercli/">Get VMInformation Using Powershell and PowerCLI</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>It&#8217;s always a good idea to get a high level overview of what&#8217;s going on with your VMware environment.  When it comes to VMs, the command Get-VM, has a lot of useful information regarding your virtual machines. Today we&#8217;re going to develop a script that builds on top of that.  The <strong>Get VMInformation script</strong> is useful if you want an export of where everything is located, network names and  guest OS.  This Powershell script will even check if vmtools is up to date so you can see which VMs need an update.  I had a lot of fun developing the script so let&#8217;s get to it.</p>
<h2>Get VMInformation Using Powershell and PowerCLI</h2>
<pre class="brush: powershell; title: ; notranslate">
Function Get-VMInformation {
&lt;#
.SYNOPSIS
    Get information from a VM object. Properties inlcude Name, PowerState, vCenterServer, Datacenter, Cluster, VMHost, Datastore, Folder, GuestOS, NetworkName, IPAddress, MacAddress, VMTools


.NOTES   
    Name: Get-VMInformation
    Author: theSysadminChannel
    Version: 1.0
    DateCreated: 2019-Apr-29


.EXAMPLE
    For updated help and examples refer to -Online version.


.LINK
    https://thesysadminchannel.com/get-vminformation-using-powershell-and-powercli -
    
#&gt;

    [CmdletBinding()]

    param(
        [Parameter(
            Position=0,
            ParameterSetName=&quot;NonPipeline&quot;
        )]
        [Alias(&quot;VM&quot;)]
        [string[]]  $Name,


        [Parameter(
            Position=1,
            ValueFromPipeline=$true,
            ValueFromPipelineByPropertyName=$true,
            ParameterSetName=&quot;Pipeline&quot;
            )]
        [PSObject[]]  $InputObject

    )


    BEGIN {
        if (-not $Global:DefaultVIServer) {
            Write-Error &quot;Unable to continue.  Please connect to a vCenter Server.&quot; -ErrorAction Stop
        }

        #Verifying the object is a VM
        if ($PSBoundParameters.ContainsKey(&quot;Name&quot;)) {
            $InputObject = Get-VM $Name
        }

        $i = 1
        $Count = $InputObject.Count
    }

    PROCESS {
        if (($null -eq $InputObject.VMHost) -and ($null -eq $InputObject.MemoryGB)) {
            Write-Error &quot;Invalid data type. A virtual machine object was not found&quot; -ErrorAction Stop
        }

        foreach ($Object in $InputObject) {
            try {
                $vCenter = $Object.Uid -replace &quot;.+@&quot;; $vCenter = $vCenter -replace &quot;:.+&quot;
                [PSCustomObject]@{
                    Name        = $Object.Name
                    PowerState  = $Object.PowerState
                    vCenter     = $vCenter
                    Datacenter  = $Object.VMHost | Get-Datacenter | select -ExpandProperty Name
                    Cluster     = $Object.VMhost | Get-Cluster | select -ExpandProperty Name
                    VMHost      = $Object.VMhost
                    Datastore   = ($Object | Get-Datastore | select -ExpandProperty Name) -join ', '
                    FolderName  = $Object.Folder
                    GuestOS     = $Object.ExtensionData.Config.GuestFullName
                    NetworkName = ($Object | Get-NetworkAdapter | select -ExpandProperty NetworkName) -join ', '
                    IPAddress   = ($Object.ExtensionData.Summary.Guest.IPAddress) -join ', '
                    MacAddress  = ($Object | Get-NetworkAdapter | select -ExpandProperty MacAddress) -join ', '
                    VMTools     = $Object.ExtensionData.Guest.ToolsVersionStatus2
                }

            } catch {
                Write-Error $_.Exception.Message

            } finally {
                if ($PSBoundParameters.ContainsKey(&quot;Name&quot;)) {
                    $PercentComplete = ($i/$Count).ToString(&quot;P&quot;)
                    Write-Progress -Activity &quot;Processing VM: $($Object.Name)&quot; -Status &quot;$i/$count : $PercentComplete Complete&quot; -PercentComplete $PercentComplete.Replace(&quot;%&quot;,&quot;&quot;)
                    $i++
                } else {
                    Write-Progress -Activity &quot;Processing VM: $($Object.Name)&quot; -Status &quot;Completed: $i&quot;
                    $i++
                }
            }
        }
    }

    END {}
}

</pre>
<p>&nbsp;</p>
<p>Copy the script to a folder and let&#8217;s go over some of the usage and examples.  Since Get-VM already displays the basic info such as CPU, memory etc.. in the default output, I didn&#8217;t think it was necessary to add those properties in the script.</p>
<h4>Get-VMInformation Examples and Usage</h2>
<p>First things first, we&#8217;ll need to load the function into memory and connect to a vcenter server in order to query the information that we&#8217;re looking for.  If you&#8217;re not connected, the script will output an error saying its unable to continue.</p>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2020/01/Connect-to-a-vcenter-server-PowerCLI.png" target="_blank" rel="noopener noreferrer"><img fetchpriority="high" decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2020/01/Connect-to-a-vcenter-server-PowerCLI.png" alt="Get VMInformation - Connect to a vcenter server Error - PowerCLI" width="899" height="200" class="aligncenter size-full wp-image-1744" srcset="https://thesysadminchannel.com/wp-content/uploads/2020/01/Connect-to-a-vcenter-server-PowerCLI.png?v=1578865931 899w, https://thesysadminchannel.com/wp-content/uploads/2020/01/Connect-to-a-vcenter-server-PowerCLI-768x171.png?v=1578865931 768w" sizes="(max-width: 899px) 100vw, 899px" /></a></p>
<pre class="brush: powershell; title: ; notranslate">
#import the PowerCLI module
Import-Module VMware.PowerCLI

#Connect to a vcenter server
Connect-VIServer -Server vcenter.thesysadminchannel.com

#Load the function into memory.  This is assuming your file is located in C:\Scripts
. 'C:\Scripts\Get-VMInformation.ps1'

#Get vm information for PAC-DC01.  
PS C:\&gt; Get-VMInformation -Name PAC-DC01

Name        : PAC-DC01
PowerState  : PoweredOn
vCenter     : vcenter.thesysadminchannel.com
Datacenter  : US
Cluster     : Cluster-01
VMHost      : esx.thesysadminchannel.com
Datastore   : ESX_Local
Folder      : VMs
GuestOS     : Microsoft Windows Server 2012 (64-bit)
NetworkName : DPortGroup
IPAddress   : 10.0.0.100
MacAddress  : xx:xx:xx:xx:xx:xx
VMTools     : guestToolsCurrent

</pre>
<p>&nbsp;</p>
<p>Since the function allows for pipeline input, we can get an array in VMs from a cluster or datacenter and just pipe it to the function. We will just have to make sure the Get-VM cmdlet is used before the Get-VMInformation to get the objects.</p>
<pre class="brush: powershell; title: ; notranslate">

#EXAMPLE 1 - Gets the VM information for all VMs that are in the specified cluster within the US Datacenter and VCSA01 vcenter server.
    Get-Cluster Cluster-01 -Server vCSA01 -Location US | Get-VM | Get-VMInformation

#EXAMPLE 2 - Gets VM information for VMs 1 and 2
    Get-VM VM1, VM2 | Get-VMInformation

#EXAMPLE 3 - Gets VM information for VMs 1 and 2
    Get-VMInformation -Name VM1, VM2

</pre>
<p>&nbsp;</p>
<p>I hope you found as much value in the Get-VMInformation script as I did. Let me know in the comments if you would like me to develop a script that has some usefulness to the general population.</p>
<p>For more VMware related articles take a look at <a href="https://thesysadminchannel.com/vmware/" rel="noopener noreferrer" target="_blank">VMware Gallery</a> or stop by our Youtube Channel with <a href="https://www.youtube.com/c/theSysadminChannel" rel="noopener noreferrer" target="_blank">VMware Videos</a></p>
<p>The post <a href="https://thesysadminchannel.com/get-vminformation-using-powershell-and-powercli/">Get VMInformation Using Powershell and PowerCLI</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/get-vminformation-using-powershell-and-powercli/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1741</post-id>	</item>
	</channel>
</rss>
