<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>http://vwiki.co.uk/index.php?action=history&amp;feed=atom&amp;title=Virtual_Machine_PowerCLI_One-Liners</id>
	<title>Virtual Machine PowerCLI One-Liners - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://vwiki.co.uk/index.php?action=history&amp;feed=atom&amp;title=Virtual_Machine_PowerCLI_One-Liners"/>
	<link rel="alternate" type="text/html" href="http://vwiki.co.uk/index.php?title=Virtual_Machine_PowerCLI_One-Liners&amp;action=history"/>
	<updated>2026-05-25T08:39:20Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>http://vwiki.co.uk/index.php?title=Virtual_Machine_PowerCLI_One-Liners&amp;diff=2638&amp;oldid=prev</id>
		<title>Sstrutt: Added Google Ad</title>
		<link rel="alternate" type="text/html" href="http://vwiki.co.uk/index.php?title=Virtual_Machine_PowerCLI_One-Liners&amp;diff=2638&amp;oldid=prev"/>
		<updated>2016-10-04T15:00:33Z</updated>

		<summary type="html">&lt;p&gt;Added Google Ad&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:00, 4 October 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{#widget:Widget:GoogleAdSenseSkyscraper}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Get list of VM&amp;#039;s ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Get list of VM&amp;#039;s ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Get list of VM&amp;#039;s&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Get list of VM&amp;#039;s&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l15&quot;&gt;Line 15:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 16:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt; Get-VM -Location (Get-vApp &amp;quot;vApp name&amp;quot;) &amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt; Get-VM -Location (Get-vApp &amp;quot;vApp name&amp;quot;) &amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{#widget:Widget:GoogleAdSenseSkyscraper}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Get VM guest Info ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Get VM guest Info ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Get VM guest OS info (IP address, etc)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Get VM guest OS info (IP address, etc)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Sstrutt</name></author>
	</entry>
	<entry>
		<id>http://vwiki.co.uk/index.php?title=Virtual_Machine_PowerCLI_One-Liners&amp;diff=1664&amp;oldid=prev</id>
		<title>Sstrutt: Initial creation - content from PowerCLI One-Liners page</title>
		<link rel="alternate" type="text/html" href="http://vwiki.co.uk/index.php?title=Virtual_Machine_PowerCLI_One-Liners&amp;diff=1664&amp;oldid=prev"/>
		<updated>2012-01-26T14:44:10Z</updated>

		<summary type="html">&lt;p&gt;Initial creation - content from PowerCLI One-Liners page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Get list of VM&amp;#039;s ==&lt;br /&gt;
Get list of VM&amp;#039;s&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt; Get-VM &amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Sort by Name === &lt;br /&gt;
Get list of VM&amp;#039;s, sorted by name&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt; Get-VM | Sort -Property Name &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Within a Folder ===&lt;br /&gt;
Get VM within a specific folder (for when you&amp;#039;ve VM&amp;#039;s with identical names if different folders)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt; Get-VM -Name MyVM -Location (Get-Folder -Name &amp;quot;MyFolder&amp;quot;) &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Within a vApp ===&lt;br /&gt;
Get VM within a specific vApp&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt; Get-VM -Location (Get-vApp &amp;quot;vApp name&amp;quot;) &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get VM guest Info ==&lt;br /&gt;
Get VM guest OS info (IP address, etc)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt; Get-VMGuest -VM (Get-VM -Name MyVM) &amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Get VM&amp;#039;s UUID ==&lt;br /&gt;
Get list of VM&amp;#039;s and their UUID&amp;#039;s&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt; Get-VM MyVM | %{(Get-View $_.Id).config.uuid} &amp;lt;/source&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
== Get VM&amp;#039;s VMX Path ==&lt;br /&gt;
Get list of virtual machine config file paths in a particular vApp (for VM&amp;#039;s in a folder use &amp;lt;code&amp;gt;Get-Folder&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;Get-vApp&amp;lt;/code&amp;gt;)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt; Get-VM -Location (Get-vApp &amp;quot;vApp Name&amp;quot;) | Get-View | %{$_.Config.Files.VmPathName} | Sort &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Get VM Power On/Off Events ==&lt;br /&gt;
Get Power On/Off times and events for VM&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt; get-VM MyVM | Get-VIEvent | Where {$_.fullFormattedMessage -like &amp;quot;*Power*&amp;quot;} &amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== Migration ==&lt;br /&gt;
=== Storage vMotion ===&lt;br /&gt;
Storage vMotion (SvMotion) a VM to a different datastore, most commonly used on ESX3 / VI3 where storage vMotion is supported by the infrastructure, but not the VI Client!&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt; Get-VM MyVM | Move-VM -datastore (Get-datastore &amp;quot;DestinationDatastore&amp;quot;) &amp;lt;/source&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
=== Move VMs to New PortGroup Network ===&lt;br /&gt;
The following will reconfigure all VM in the specified folder to move from network A to network B&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt; Get-VM -Location (Get-Folder &amp;quot;InThisFolder&amp;quot;) | Get-NetworkAdapter | Where {$_.NetworkName -eq &amp;quot;Network A&amp;quot;} | Set-NetworkAdapter -NetworkName &amp;quot;Network B&amp;quot; -Confirm:$false &amp;lt;/source&amp;gt;&lt;br /&gt;
Borrowed in part from http://www.virtu-al.net/2009/10/19/powercli-mass-vm-portgroup-change/&lt;br /&gt;
&lt;br /&gt;
== Gracefully Shutdown a VM ==&lt;br /&gt;
Sends OS shutdown command via VM Tools&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt; Shutdown-VMGuest -VM (Get-VM -name &amp;quot;vserver1&amp;quot;) &amp;lt;/source&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
== Snapshots ==&lt;br /&gt;
=== Get Snapshot info for a VM ===&lt;br /&gt;
Get Snapshot size, date created, and other info for a VM&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt; Get-VM MyVM | Get-Snapshot | Select-Object -Property Name, Description, Created, SizeMB | Format-List * &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Start Snapshot on Multiple VMs ===&lt;br /&gt;
Assumes you&amp;#039;ve already got an array object of VMs containing the VM&amp;#039;s you want to snapshot (eg &amp;lt;code&amp;gt;$VMs = Get-VM -Location (Get-Folder -Name &amp;quot;MyFolder&amp;quot;)&amp;lt;/code&amp;gt; for VM&amp;#039;s in a particular folder, see [[#Get_list_of_VM.27s|Get_list_of_VM&amp;#039;s]] for further info)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt;New-Snapshot -Name &amp;quot;Pre change XYZ snapshot&amp;quot; -Description &amp;quot;Requested by TJ Hooker&amp;quot; -Memory -Quiesce -VM $vms &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Roll-back to Snapshot on Multiple VMs ===&lt;br /&gt;
Rolls back VM&amp;#039;s to snapshots previously taken (assumes you&amp;#039;ve already got an array object of VMs containing the VM&amp;#039;s you want to rollback for)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt;foreach ($vm in $vms) {Set-VM -VM $vm -Snapshot (Get-Snapshot -VM $vm -Name &amp;quot;Pre change XYZ snapshot&amp;quot;) -Confirm:$false}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Delete/Merge Snapshot on Multiple VMs ===&lt;br /&gt;
Deletes snapshots previously taken so that VMs continue as they are currently, but lose the ability to fall-back to the snapshot (assumes you&amp;#039;ve already got an array object of VMs containing the VM&amp;#039;s you want to delete snapshots for)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;powershell&amp;quot;&amp;gt;foreach ($vm in $vms) {Remove-Snapshot -Snapshot (Get-Snapshot -VM $vm -Name &amp;quot;Pre change XYZ snapshot&amp;quot;) -Confirm:$false}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:PowerCLI]]&lt;br /&gt;
[[Category:Virtual Machine]]&lt;/div&gt;</summary>
		<author><name>Sstrutt</name></author>
	</entry>
</feed>