<?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>Hypervisor.fr &#187; oneliner</title>
	<atom:link href="http://www.hypervisor.fr/?feed=rss2&#038;tag=oneliner" rel="self" type="application/rss+xml" />
	<link>http://www.hypervisor.fr</link>
	<description>French Bare-Metal weblog</description>
	<lastBuildDate>Wed, 26 Jun 2024 22:42:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The (old) Ladykillers</title>
		<link>http://www.hypervisor.fr/?p=5789</link>
		<comments>http://www.hypervisor.fr/?p=5789#comments</comments>
		<pubDate>Wed, 12 Apr 2017 17:51:49 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=5789</guid>
		<description><![CDATA[Pour bien commencer le printemps et son grand ménage traditionnel, nous vous proposons un petit oneliner qui vous affichera la liste des vm éteintes avec la date du poweroff basée sur la dernière modification du fichier nvram (qui coincide au fameux &#8220;VMX has left the building&#8221; dans le vmware.log) donc pas de dépendance avec la [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Pour bien commencer le printemps et son grand ménage traditionnel, nous vous proposons un petit oneliner qui vous affichera la liste des vm éteintes avec la date du poweroff <strong>basée sur la dernière modification du fichier nvram</strong> (qui coincide au fameux &#8220;VMX has left the building&#8221; dans le vmware.log) donc pas de dépendance avec la stratégie de rétention des tasks et events de votre VCDB.</p>
<p style="text-align: center;"><a href="http://files.hypervisor.fr/img/The_old_Ladykillers/ds_browser_nvram.png" title="ds_browser_nvram" rel="lightbox[5789]"><img class="alignnone size-thumbnail wp-image-5790" title="ds_browser_nvram" src="http://www.hypervisor.fr/wp-content/uploads/2017/04/ds_browser_nvram-150x150.png" alt="" width="150" height="150" /></a> <a href="http://files.hypervisor.fr/img/The_old_Ladykillers/vmx_has_left_the_build_log.png" title="vmx_has_left_the_build_log" rel="lightbox[5789]"><img class="alignnone size-thumbnail wp-image-5791" title="vmx_has_left_the_build_log" src="http://www.hypervisor.fr/wp-content/uploads/2017/04/vmx_has_left_the_build_log-150x150.png" alt="" width="150" height="150" /></a></p>
<p style="text-align: justify;">
<p style="text-align: justify;">Nous avons ajouté la taille de la VM pour vous motiver à faire un VeeamZIP et à en finir définitivement avec ces VM qui risque d&#8217;être redémarrées après un crash d&#8217;ESX&#8230;</p>
<p style="text-align: center;"><img class="aligncenter" src="http://files.hypervisor.fr/img/The_old_Ladykillers/old_vm_off_ogv.png" alt="" width="495" height="596" /></p>
<pre class="brush: powershell; title: ; notranslate">get-view -viewtype virtualmachine -property name,runtime,layoutex|?{$_.Runtime.PowerState -eq &quot;poweredOff&quot; -and $_.Runtime.ConnectionState -eq &quot;connected&quot; -and !$_.config.template}|?{$_.LayoutEx.File|?{$_.type -match &quot;nvram&quot;}}|%{$_|select Name, @{n=&quot;Modification&quot;;e={((get-view (get-view -viewtype datastore –filter @{&quot;Name&quot;=($_.LayoutEx.File|?{$_.type -eq &quot;nvram&quot;}).name.split(&quot;[]&quot;)[1]}).browser).SearchDatastore(($_.LayoutEx.File|?{$_.type -eq &quot;nvram&quot;}).name.split(&quot;/&quot;)[0],(New-Object VMware.Vim.HostDatastoreBrowserSearchSpec -property @{matchPattern=(&quot;*.nvram&quot;); details=(New-Object VMware.Vim.FileQueryFlags -property @{modification=$true})}))|%{$_.file}).Modification}}, @{n=&quot;SizeGB&quot;;e={[math]::round(($_.LayoutEx.File|measure -Property size -sum).sum/1GB,1)}}}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=5789</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>storageRM level 1</title>
		<link>http://www.hypervisor.fr/?p=5252</link>
		<comments>http://www.hypervisor.fr/?p=5252#comments</comments>
		<pubDate>Fri, 08 Aug 2014 13:31:57 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[Kb]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[graylog2]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[SIOC]]></category>
		<category><![CDATA[syslog]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=5252</guid>
		<description><![CDATA[Instruit par la kb Troubleshooting Storage I/O Control (1022091), nous nous sommes rendu compte qu&#8217;en fixant le log level à 1, le service storageRM crachait les informations de latency, qdepth et iops des datastores concernés dans les logs d&#8217;ESXi (et donc vers le(s) serveur(s) syslog) toutes les 4 secondes. Sur une grosse infra ça peut faire [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Instruit par la kb <a href="http://kb.vmware.com/kb/1022091" target="_blank">Troubleshooting Storage I/O Control (1022091)</a>, nous nous sommes rendu compte qu&#8217;en fixant le log level à 1, le service storageRM crachait les informations de latency, qdepth et iops des datastores concernés dans les logs d&#8217;ESXi (et donc vers le(s) serveur(s) syslog) <a href="http://cormachogan.com/2013/06/20/storage-io-control-workload-injector-behaviour/" target="_blank">toutes les 4 secondes</a>. Sur une grosse infra ça peut faire beaucoup mais ça offre de belles perspective de monitoring/troubleshooting :</p>
<p style="text-align: center;"><a href="http://files.hypervisor.fr/img/StorageRM_1/sioc_avglatency_agg.png" target="_blank"><img class="aligncenter" src="http://files.hypervisor.fr/img/StorageRM_1/sioc_avglatency_agg.png" alt="" width="494" height="407" /></a></p>
<p style="text-align: center;"><a href="http://files.hypervisor.fr/img/StorageRM_1/sioc_datastore.png" title="sioc_datastore" rel="lightbox[5252]"><img class="alignnone size-thumbnail wp-image-5256" title="sioc_datastore" src="http://www.hypervisor.fr/wp-content/uploads/2014/08/sioc_datastore-150x150.png" alt="" width="150" height="150" /></a> <a href="http://files.hypervisor.fr/img/StorageRM_1/sioc_avglatency.png" title="sioc_avglatency" rel="lightbox[5252]"><img class="alignnone size-thumbnail wp-image-5255" title="sioc_avglatency" src="http://www.hypervisor.fr/wp-content/uploads/2014/08/sioc_avglatency-150x150.png" alt="" width="150" height="150" /></a> <a href="http://files.hypervisor.fr/img/StorageRM_1/sioc_iops.png" title="sioc_iops" rel="lightbox[5252]"><img class="alignnone size-thumbnail wp-image-5257" title="sioc_iops" src="http://www.hypervisor.fr/wp-content/uploads/2014/08/sioc_iops-150x150.png" alt="" width="150" height="150" /></a></p>
<p style="text-align: left;">Et voici le oneliner PowerCLI pour le faire vite et bien :</p>
<pre class="brush: powershell; title: ; notranslate">Get-View -ViewType HostSystem|?{$_.Runtime.ConnectionState -eq &quot;connected&quot; -and $_.config.product.ProductLineId -eq &quot;embeddedEsx&quot; -and ($_.Config.Option|?{$_.Key -eq &quot;Misc.SIOControlLogLevel&quot;}).Value -ne &quot;1&quot;}|%{(Get-View $_.ConfigManager.AdvancedOption).UpdateOptions((New-Object VMware.Vim.OptionValue -Property @{Key=&quot;Misc.SIOControlLogLevel&quot;;Value=[Int64]1}))}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=5252</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>The vExpendables</title>
		<link>http://www.hypervisor.fr/?p=4633</link>
		<comments>http://www.hypervisor.fr/?p=4633#comments</comments>
		<pubDate>Fri, 29 Mar 2013 08:23:29 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[Kb]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[DVS]]></category>
		<category><![CDATA[DVSwitch]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=4633</guid>
		<description><![CDATA[C&#8217;est le tweet de Arne Fokkema qui nous a fais découvrir une feature de DVS 5.0+ qui ne semble pas très connue, l&#8217;autoExpand. Comme son nom le laisse deviner, cette fonctionnalité relègue au placard tous les scripts de check de ports encore disponibles que vous passiez jadis sur votre infra pour ne pas vous retrouver en rade [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">C&#8217;est <a href="https://twitter.com/afokkema/status/315107918443864064" target="_blank">le tweet de Arne Fokkema</a> qui nous a fais découvrir une feature de DVS 5.0+ qui ne semble pas très connue, l&#8217;<a href="http://blogs.vmware.com/vsphere/2012/02/automating-auto-expand-configuration-for-a-dvportgroup-in-vsphere-5.html" target="_blank"><strong>autoExpand</strong></a>. Comme son nom le laisse deviner, cette fonctionnalité relègue au placard tous les scripts de check de ports encore disponibles que vous passiez jadis sur votre infra pour ne pas vous retrouver en rade au prochain déploiement de VM.</p>
<p style="text-align: justify;">En effet, après avoir activé l&#8217;autoExpand, le nombre de ports utilisables d&#8217;un DVPortgroup (en Static binding aka <a href="http://vijava.sourceforge.net/vSphereAPIDoc/ver51/ReferenceGuide/vim.dvs.DistributedVirtualPortgroup.PortgroupType.html" target="_blank">earlyBinding</a>) se verra incrémenté automatiquement de 10 lorsqu&#8217;aucun port n&#8217;est disponible pour une nouvelle VM. Il y a également une fonction d&#8217;autoShrink décrite dans l&#8217;API Reference mais c&#8217;est une peu vague :</p>
<blockquote>
<p style="text-align: justify;">When this property is set to true, the portgroup becomes a potential candidate for auto-shrink. Once the portgroup has auto-expanded then its disconnected ports are likely to be deleted automatically, as a part of auto-shrink step, <strong>if there are more than certain number of free ports</strong>. If the portgroup never auto-expanded, then it will never lose any free ports.</p>
</blockquote>
<p style="text-align: justify;">Sachant que cette fonction est activé par défaut sur les DVSwitch 5.1, nous avons voulu vérifier si c&#8217;était également le cas lors d&#8217;une migration :</p>
<p style="text-align: center;"><a href="http://files.hypervisor.fr/img/dvpg50_autoexpand.png" target="_blank"><img class="aligncenter" src="http://files.hypervisor.fr/img/dvpg50_autoexpand.png" alt="" width="516" height="348" /></a></p>
<p style="text-align: center;"><a href="http://files.hypervisor.fr/img/dvpg50_autoexpand_up.png" target="_blank"><img class="aligncenter" src="http://files.hypervisor.fr/img/dvpg50_autoexpand_up.png" alt="" width="516" height="329" /></a></p>
<p style="text-align: left;">On constate donc que même <strong>après avoir upgradé le DVSwitch 5.0.0 en 5.1.0, l&#8217;autoExpand est toujours désactivé</strong>. Mais pas pour longtemps <img src='http://www.hypervisor.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: justify;">Après analyse du script PowerCLI d&#8217;Arne et de l&#8217;API Reference, nous avons constaté que les DVUplinks &#8220;disposaient&#8221; de cette fonctionnalité (<strong>désactivée dans tous les cas et à ne probablement pas activer</strong>) car comme nous le confirme <a href="http://www.doublecloud.org/2011/06/tagging-an-invisible-feature-in-vsphere/" target="_blank">Steve Jin, ce ne sont que des DVPortgroup avec un tag spécifique</a> (SYSTEM/DVS.UPLINKPG). De plus, lors de la reconfiguration du DVPortgroup, la propriété <a href="http://vijava.sourceforge.net/vSphereAPIDoc/ver51/ReferenceGuide/vim.dvs.DistributedVirtualPortgroup.ConfigInfo.html#configVersion" target="_blank">configVersion</a> devrait être incrémentée. Et pour finir, en onliner c&#8217;est plus sexy :</p>
<pre class="brush: powershell; title: ; notranslate">Get-View -ViewType DistributedVirtualPortgroup|?{!($_.Tag|?{$_.Key -eq &quot;SYSTEM/DVS.UPLINKPG&quot;}) -and !$_.Config.autoExpand}|%{$_.ReconfigureDVPortgroup_Task((New-Object VMware.Vim.DVPortgroupConfigSpec -Property @{autoExpand=&quot;True&quot;;ConfigVersion=[int32]$_.Config.ConfigVersion+1}))}</pre>
<p><strong>Le script n&#8217;active la fonctionnalité que sur les DVPortgroup ne l&#8217;ayant pas déjà (hors DVUplinks) et incrémente la propriété ConfigVersion de 1</strong> :</p>
<p style="text-align: center;"><a href="http://files.hypervisor.fr/img/dvpg50_autoexpand_ex.png" target="_blank"><img class="aligncenter" src="http://files.hypervisor.fr/img/dvpg50_autoexpand_ex.png" alt="" width="516" height="475" /></a></p>
<p style="text-align: left;">Et pour ceux qui voudraient savoir quand de nouveaux ports ont été ajoutés ou supprimés, il y a une alarme pour ça (<em>Monitor : vSphere Distributed Swiches</em>) :</p>
<p style="text-align: center;"><a href="http://files.hypervisor.fr/img/dvpg50_autoexpand_alarm.png" target="_blank"><img class="aligncenter" src="http://files.hypervisor.fr/img/dvpg50_autoexpand_alarm.png" alt="" width="523" height="340" /></a></p>
<p style="text-align: left;">
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=4633</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ZFS snapshot auto-destroy onliner</title>
		<link>http://www.hypervisor.fr/?p=4484</link>
		<comments>http://www.hypervisor.fr/?p=4484#comments</comments>
		<pubDate>Thu, 13 Dec 2012 07:12:17 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[ZFS]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[nexenta]]></category>
		<category><![CDATA[oneliner]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=4484</guid>
		<description><![CDATA[MAJ 23.05.2013 : Et voici un cas d&#8217;usage réel en production.
Tous ceux qui ont eu à affronter un manque d&#8217;espace critique sur un zpool se sont au moins une fois posé la question suivante : Pourquoi ZFS n&#8217;est il pas capable de supprimer automatiquement les plus anciens snapshot pour libérer de l&#8217;espace en cas de [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 23.05.2013</span><em> : <a href="https://twitter.com/hypervisor_fr/status/337986858892017665/photo/1" target="_blank">Et voici un cas d&#8217;usage réel en production</a>.</em></em></p>
<p style="text-align: justify;">Tous ceux qui ont eu à affronter un manque d&#8217;espace critique sur un zpool se sont au moins une fois posé la question suivante : <strong><strong>Pourquoi ZFS n&#8217;est il pas capable de supprimer automatiquement les plus anciens snapshot pour libérer de l&#8217;espace en cas de besoin ?</strong></strong></p>
<p style="text-align: justify;">La réponse est évidement parce que ce n&#8217;est pas (encore) intégré à ZFS mais peut être que le futur principe de &#8220;<a href="http://blog.delphix.com/csiden/files/2012/01/ZFS_Feature_Flags.pdf">feature flags</a>&#8221; (qui remplacera la fameuse &#8220;version&#8221; de ZFS) facilitera la naissance de cette fonctionnalité tant espérée. En attendant, il y a toujours la bonne vielle crontab toujours très pratique et si on pimente à la sauce oneliner, ça donne quelque chose d&#8217;un peu trash mais fonctionnel :</p>
<pre class="brush: bash; title: ; notranslate">for zpool in `zpool list -H -o name,capacity | sed &quot;s/%//g&quot; | awk '{ if ( $2 &gt; 80 ) { print $1; } }'`; do zfs list -H -o name -t snapshot | grep -E &quot;^$zpool&quot; | head -n $[$(zfs list -H -o name -t snapshot | grep -E &quot;^$zpool&quot;|wc -l) / 5 + 1]  | xargs -n1 zfs destroy -R ; done</pre>
<p style="text-align: justify;"><strong>Ce oneliner détruira récursivement 25% des plus vieux snapshots</strong> (+1 pour éviter les cas ou 25% feraient moins d&#8217;1 snapshot) <strong>d&#8217;un zpool si le remplissage dépasse les 80%</strong>.</p>
<p style="text-align: justify;">Voici une démo de ce script sur un zpool soumis à remplissage perpétuel (dd en boucle + snapshot toutes les minutes) :</p>
<p style="text-align: center;"><a href="http://files.hypervisor.fr/img/zfs_snapshot_autoremove.png" target="_blank"><img class="aligncenter" src="http://files.hypervisor.fr/img/zfs_snapshot_autoremove.png" alt="" width="482" height="231" /></a></p>
<p style="text-align: justify;">Observations du graphique : jusqu&#8217;à 10h nous avons programmé le script toutes les minutes, puis toutes les 5min jusqu&#8217;à 15h30, puis nous l&#8217;avons désactivé et le zpool sature presque immédiatement après.</p>
<p style="text-align: left;">Voici l&#8217;extrait de la crontab de notre nexenta de test :</p>
<pre class="brush: bash; title: ; notranslate">* * * * * for zpool in `zpool list -H -o name,capacity | sed &quot;s/\%//g&quot; | awk '{ if ( \$2 &gt; 80 ) { print \$1; } }'`; do zfs list -H -o name -t snapshot | grep -E &quot;^$zpool&quot; | head -n $[$(zfs list -H -o name -t snapshot | grep -E &quot;^$zpool&quot;|wc -l) / 5 + 1]  | xargs -n1 zfs destroy -R ; done</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=4484</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get-EsxCli de PowerCLI v5 supporte le &#8220;SSO&#8221;</title>
		<link>http://www.hypervisor.fr/?p=3947</link>
		<comments>http://www.hypervisor.fr/?p=3947#comments</comments>
		<pubDate>Mon, 16 Jul 2012 00:08:28 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[esxcli]]></category>
		<category><![CDATA[Get-EsxCli]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[sso]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=3947</guid>
		<description><![CDATA[Alors que nous scriptions le check du paramètre UNMAP des primitives VAAI avec la cmdlet Get-EsxCli, nous nous sommes aperçu par hasard que contrairement à celle de la v4 de PowerCLI cette cmdlet avait un paramètre &#8221;VMHost&#8221; en plus du paramètre &#8221;Server&#8221; déjà présente dans la v4. Sachant que cette cmdlet ne pouvait être exécutée que lors d&#8217;une session direct avec un (ou plusieurs) ESX lors son [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Alors que nous scriptions le check du paramètre <a href="http://kb.vmware.com/kb/2007427" target="_blank">UNMAP des primitives VAAI</a> avec <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/html/Get-EsxCli.html" target="_blank">la cmdlet Get-EsxCli</a>, nous nous sommes aperçu par hasard que contrairement à celle de la v4 de PowerCLI cette cmdlet avait un paramètre &#8221;VMHost&#8221; en plus du paramètre &#8221;Server&#8221; déjà présente dans la v4. Sachant que cette cmdlet ne pouvait être exécutée que lors d&#8217;une session direct avec un (ou plusieurs) ESX <a href="http://www.hypervisor.fr/?p=2507" target="_blank">lors son apparition dans le PowerCLI 4.1 U1</a>, la présence du paramètre &#8221;VMHost&#8221; nous a paru plus que suspect.</p>
<p style="text-align: justify;">Et bien nous en a pris car cet indice nous a permis de découvrir (1 an plus tard&#8230;) que <strong>la cmdlet Get-EsxCli de PowerCLI 5+ ne nécessite pas de connections direct aux ESX</strong> (mais <a href="http://www.vmware.com/support/developer/PowerCLI/changelog.html#PowerCLI50" target="_blank">uniquement avec un vCenter 5+ comme en témoigne le changelog</a>) :</p>
<blockquote>
<p style="text-align: justify;">Added vCenter Server support for Get-EsxCli. (requires vCenter Server 5.0 or later)</p>
</blockquote>
<p style="text-align: justify;">Vous pouvez donc facilement vérifier l&#8217;état du paramètre UNMAP&#8230;</p>
<p style="text-align: justify;"><img class="aligncenter" src="http://files.hypervisor.fr/img/get-esxcli_v5/get-esxcli_sso_unmap.png" alt="" width="518" height="136" /></p>
<pre class="brush: powershell; title: ; notranslate">Get-VMHost|select Name, @{n=&quot;UNMAP&quot;;e={$(($_|Get-EsxCli).system.settings.advanced.list(&quot;/VMFS3/EnableBlockDelete&quot;)).IntValue}}</pre>
<p style="text-align: justify;">&#8230; Ou afficher la liste des claimrule (<a href="http://kb.vmware.com/kb/1009449" target="_blank">pratique pour masquer un path</a>)&#8230;</p>
<p style="text-align: justify;"><img class="aligncenter" src="http://files.hypervisor.fr/img/get-esxcli_v5/get-esxcli_sso_claimrules.png" alt="" width="518" height="398" /></p>
<pre class="brush: powershell; title: ; notranslate">Get-VMHost|%{&quot; &quot;;write-host -background white -foreground red $_.Name;($_|Get-EsxCli).storage.core.claimrule.list()|ft *}</pre>
<p style="text-align: justify;">&#8230; Ou encore modifier le paramètre &#8220;<a href="http://jpaul.me/?p=2492" target="_blank">IOOperationLimit</a>&#8221; des LUN configurées en roundrobin :</p>
<p style="text-align: justify;"><img class="aligncenter" src="http://files.hypervisor.fr/img/get-esxcli_v5/get-esxcli_sso_iops.png" alt="" width="518" height="1094" /></p>
<pre class="brush: powershell; title: ; notranslate">ForEach ($VMHost in Get-VMHost){&quot; &quot;;write-host -background white -foreground red $VMHost.Name;($VMHost|Get-EsxCli).storage.nmp.device.list()|?{$_.PathSelectionPolicy -match &quot;VMW_PSP_RR&quot;}|%{($VMHost|Get-EsxCli).storage.nmp.psp.roundrobin.deviceconfig.get($_.device)}}</pre>
<pre class="brush: powershell; title: ; notranslate">ForEach ($VMHost in Get-VMHost){&quot; &quot;;write-host -background white -foreground red $VMHost.Name;($VMHost|Get-EsxCli).storage.nmp.device.list()|?{$_.PathSelectionPolicy -match &quot;VMW_PSP_RR&quot;}|%{($VMHost|Get-EsxCli).storage.nmp.psp.roundrobin.deviceconfig.get($_.device)}|?{$_.IOOperationLimit -ne 1 -and $_.LimitType -ne &quot;iops&quot;}|%{($VMHost|Get-EsxCli).storage.nmp.psp.roundrobin.deviceconfig.set($null,$_.device,&quot;1&quot;,&quot;iops&quot;,$null)}}</pre>
<p>Moralité : RTFChangelog <img src='http://www.hypervisor.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=3947</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Les scripts Powershell indispensables à votre veeam backup</title>
		<link>http://www.hypervisor.fr/?p=3749</link>
		<comments>http://www.hypervisor.fr/?p=3749#comments</comments>
		<pubDate>Thu, 22 Mar 2012 08:19:52 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[veeam]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=3749</guid>
		<description><![CDATA[MAJ 13/07/2012 : Mise à jour du script de récupération des fichiers de backup orphelins pour la v6, merci à Thierry pour le feedback.
Nous vous proposions il y a quelques temps un script qui stop les jobs en cours sur un serveur veeam backup, aujourd&#8217;hui nous allons plus loin dans la démarche avec 2 fichiers [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">MAJ 13/07/2012 : Mise à jour du script de récupération des fichiers de backup orphelins pour la v6, merci à <a href="http://www.hypervisor.fr/?p=3749&amp;cpage=1#comment-2352" target="_self">Thierry pour le feedback</a>.</p>
<p style="text-align: justify;">Nous vous proposions il y a quelques temps <a href="http://www.hypervisor.fr/?p=3442" target="_blank">un script qui stop les jobs en cours sur un serveur veeam backup</a>, aujourd&#8217;hui nous allons plus loin dans la démarche avec 2 fichiers xml correspondant à 2 export de tache planifiée pour Windows 2008 R2 contenant les commandes. <a href="http://files.hypervisor.fr/scripts/StopActiveVBRJobs.xml" target="_blank">Le fichier StopActiveVBRJobs.xml</a> va vous permettre de créer une tache planifiée qui arrêtera les jobs veeam en cours à 7h du matin, les jours de semaine, et <a href="http://files.hypervisor.fr/scripts/RetryFailedVBRJobs.xml" target="_blank">le fichier RetryFailedVBRJobs.xml</a> automatisera le retry des jobs arrêtés &#8221;manuellement&#8221; à 21h, les mêmes jours.</p>
<p style="text-align: justify;">Nous vous proposons également une <a href="http://files.hypervisor.fr/scripts/ExportVBRJobs.xml" target="_blank">tache planifiée qui automatise l&#8217;export des jobs veeam backup sur un partage CIFS</a> (\\server\share\ à ajuster) et un autre qui permet <a href="http://files.hypervisor.fr/scripts/ExportVBRRestorePoint.xml" target="_blank">d&#8217;exporter régulièrement (en xml) la liste des points de restauration possibles pour chaque vm de chaque job</a>.</p>
<p><img class="aligncenter" src="http://files.hypervisor.fr/img/veeam_rpoint_export.png" alt="" width="308" height="359" /></p>
<p style="text-align: justify;">Voici maintenant un oneliner pour un usage très particulier, celui de trouver (replacez le get-item par remove-item pour supprimer) les fichiers veeam backup orphelins dans les répertoires cibles des jobs (cela peut arriver en cas de reboot violent du serveur veeam ou indisponibilité du repository pendant un backup).</p>
<p>v5 :
<pre class="brush: powershell; title: ; notranslate">Compare-Object (Get-VBRJob|%{$_.Info.TargetDir|%{Get-ChildItem $_|%{$_.FullName}}}) (Get-VBRBackup|%{$_.GetStorages()|%{$_.FilePath}})|%{Get-Item $_.InputObject}</pre>
<p>v6 :
<pre class="brush: powershell; title: ; notranslate">Compare-Object (Get-VBRJob|%{$_.Info|%{Get-ChildItem &quot;$($_.TargetDir)\$($_.Path)&quot;|%{$_.FullName|?{$_ -match &quot;.vrb|.vbk|.vib&quot;}}}}) (Get-VBRBackup|%{$_.GetStorages()|%{$_.FilePath}})|%{Get-Item $_.InputObject}</pre>
<p style="text-align: center;"><a href="http://files.hypervisor.fr/img/veeam_lostfiles/veeam_backup_files.png" title="veeam_backup_files" rel="lightbox[3749]"><img class="alignnone size-thumbnail wp-image-3768" title="veeam_backup_files" src="http://www.hypervisor.fr/wp-content/uploads/2012/03/veeam_backup_files-150x150.png" alt="" width="150" height="150" /></a> <a href="http://files.hypervisor.fr/img/veeam_lostfiles/veeam_lost_files.png" title="veeam_lost_files" rel="lightbox[3749]"><img class="alignnone size-thumbnail wp-image-3769" title="veeam_lost_files" src="http://www.hypervisor.fr/wp-content/uploads/2012/03/veeam_lost_files-150x150.png" alt="" width="150" height="150" /></a> <a href="http://files.hypervisor.fr/img/veeam_lostfiles/veeam_lost_files_list.png" title="veeam_lost_files_list" rel="lightbox[3749]"><img class="alignnone size-thumbnail wp-image-3770" title="veeam_lost_files_list" src="http://www.hypervisor.fr/wp-content/uploads/2012/03/veeam_lost_files_list-150x150.png" alt="" width="150" height="150" /></a></p>
<p style="text-align: justify;">On continue avec un autre oneliner qui permet d&#8217;afficher la liste des vm dont la date du dernier backup veeam (si vous avez activé <a href="http://www.veeam.com/blog/using-vm-attributes-to-quickly-determine-status-of-vm-backups.html" target="_blank">la fonction qui rempli l&#8217;un des custom fields</a>, &#8220;veeam&#8221; dans notre exemple) est supérieure à 21 jours, que vous pouvez utiliser dans un script pour vous envoyez un mail périodiquement par exemple.</p>
<pre class="brush: powershell; title: ; notranslate">Get-View -Viewtype virtualmachine|select name,@{n=&quot;backup&quot;;e={[Regex]::Match(($_.value|?{$_.key -eq ((get-view (Get-View ServiceINstance).content.CustomFieldsManager).field|?{$_.name -match &quot;veeam&quot;}).key}).value, &quot;([0-9]{1,2}/){2,2}201[0-9]{1,1}[ ]*([0-9]{1,2}:?){3,3}&quot;).Value}},@{n=&quot;pool&quot;;e={(get-view $_.ResourcePool).name}}|?{$_.backup}|?{([datetime]::ParseExact(($_.backup), &quot;dd/MM/yyyy HH:mm:ss&quot;, (New-Object System.Globalization.CultureInfo(&quot;fr-FR&quot;)))) -le (get-date).AddDays(-21)}</pre>
<p><a href="http://files.hypervisor.fr/img/veeam_lostfiles/veeam_lastbackup.png" title="veeam_lastbackup" rel="lightbox[3749]"><img class="aligncenter size-full wp-image-3771" title="veeam_lastbackup" src="http://www.hypervisor.fr/wp-content/uploads/2012/03/veeam_lastbackup.png" alt="" width="401" height="301" /></a></p>
<p style="text-align: justify;">Et pour finir, un oneliner qui nous a prit un peu de temps (à cause du comportement bizarre du -ExpandProperty de la cmdlet Select-Object) qui vous permet de lister les vm présentent dans plusieurs jobs de backup.</p>
<pre class="brush: powershell; title: ; notranslate">Get-VBRBackup|select jobname,@{n=&quot;vm&quot;;e={$_.GetObjectOibsAll()|%{@($_.name,&quot;&quot;)}}}|select jobname -ExpandProperty vm|select @{n=&quot;vmname&quot;;e={$_}}, @{n=&quot;jobname&quot;;e={$_.jobname}}|?{$_.vmname}|Group-Object -Property vmname|?{$_.Count -gt 1}|select name, @{n=&quot;jobs&quot;;e={$_.group|%{$_.JobName}}}</pre>
<p><a href="http://files.hypervisor.fr/img/veeam_lostfiles/veeam_multi_job.png" title="veeam_multi_job" rel="lightbox[3749]"><img class="aligncenter size-medium wp-image-3772" title="veeam_multi_job" src="http://www.hypervisor.fr/wp-content/uploads/2012/03/veeam_multi_job-300x148.png" alt="" width="300" height="148" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=3749</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PowerCLI OneLiner repository</title>
		<link>http://www.hypervisor.fr/?p=3675</link>
		<comments>http://www.hypervisor.fr/?p=3675#comments</comments>
		<pubDate>Thu, 01 Mar 2012 08:14:23 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[VMware]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=3675</guid>
		<description><![CDATA[Plutôt que de les laisser moisir dans un coin, nous partageons nos perles de PowerCLI avec les amateurs de oneliner via notre nouvelle rubrique &#8220;One&#124;Liner&#8220;.

]]></description>
			<content:encoded><![CDATA[<p>Plutôt que de les laisser moisir dans un coin, nous partageons nos perles de PowerCLI avec les amateurs de oneliner via notre nouvelle rubrique &#8220;<a href="http://www.hypervisor.fr/?page_id=3637" target="_blank">One|Liner</a>&#8220;.</p>
<p><a href="http://kimjongillookingatthings.tumblr.com/"><img class="aligncenter" src="http://files.hypervisor.fr/img/oneliner/kimjongiloneliner.png" alt="" width="550" height="349" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=3675</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[PSH] Raiders of the Lost VM files &#8211; MAJ</title>
		<link>http://www.hypervisor.fr/?p=3612</link>
		<comments>http://www.hypervisor.fr/?p=3612#comments</comments>
		<pubDate>Fri, 24 Feb 2012 08:47:20 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[VMware]]></category>
		<category><![CDATA[ZFS]]></category>
		<category><![CDATA[CBT]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[snapshot]]></category>
		<category><![CDATA[vmdk]]></category>
		<category><![CDATA[VMFS]]></category>
		<category><![CDATA[vmx]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=3612</guid>
		<description><![CDATA[MAJ 23/05/2015 : Mise à jours des scripts pour exclure que les fichiers &#8220;.lck&#8221; (VSAN).
MAJ 30/10/2012 : Mise à jours des scripts pour n&#8217;exclure que les vm &#8220;invalid&#8221; ou &#8220;orphaned&#8221;.
MAJ 06/07/2012 : Mise à jour des scripts pour exclure &#8220;*/hostCache/*&#8221; pour ne pas remonter les fichiers vswp de la fonction Host Cache d&#8217;ESXi 5.
MAJ 05/07/2012 [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 23/05/2015</span> : Mise à jours des scripts pour exclure que les fichiers &#8220;.lck&#8221; (VSAN).</em></p>
<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 30/10/2012</span> : Mise à jours des scripts pour n&#8217;exclure que les vm &#8220;invalid&#8221; ou &#8220;orphaned&#8221;.</em></p>
<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 06/07/2012</span> : Mise à jour des scripts pour exclure &#8220;*/hostCache/*&#8221; pour ne pas remonter <a href="http://www.yellow-bricks.com/2011/08/18/swap-to-host-cache-aka-swap-to-ssd/" target="_blank">les fichiers vswp de la fonction Host Cache d&#8217;ESXi 5</a>.</em></p>
<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 05/07/2012</span> : Mise à jour des scripts pour intégrer les fichiers vswp.xxxxxx, <a href="http://vmice.wordpress.com/2012/07/04/vm-swapfiles-leftover-swapfiles/" target="_blank">merci à Larus Hjartarson pour l&#8217;idée</a>.</em></p>
<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 21/03/2012</span> : Mise à jour des scripts pour exclure &#8220;var/tmp/cache&#8221; dans le cas d&#8217;une redirection de la partition scratch sur un datastore.</em></p>
<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 06/03/2012</span> : Mise à jour des scripts pour le support des <strong>multi-datacenter/multi-vcenter</strong>, des snapshot NetApp et des fichiers zdump qui trainent.</em></p>
<p style="text-align: center;"><em><a href="http://files.hypervisor.fr/img/lostvmfilemulti.png" target="_blank"><img class="aligncenter" src="http://files.hypervisor.fr/img/lostvmfilemulti.png" alt="" width="521" height="379" /></a><br />
</em></p>
<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 28/02/2012</span><em> :</em></em><em> Mise à jour des scripts suite à une erreur dans le &#8220;SideIndicator&#8221;</em></p>
<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 24/02/2012</span><em> : </em></em><em>Et pour ceux qui ont <strong>*<span style="color: #ff0000;">VRAIMENT</span>*</strong> confiance, voici le script pour supprimer les fichiers vswp orphelins (et si vraiment vous en avez, vous pouvez changer le filtrage au niveau du </em><strong>|?{$_.lostfile -match &#8220;vswp&#8221;}</strong>)<em> :</em></p>
<pre class="brush: powershell; title: ; notranslate">foreach ($lost in (compare -passthru -property path $(foreach ($ds in ((get-view -ViewType datastore|sort name -unique|?{$_.summary.accessible}|%{(get-view $_.browser).SearchDatastoreSubFolders($(&quot;[&quot; + $_.Name + &quot;]&quot;),(New-Object VMware.Vim.HostDatastoreBrowserSearchSpec -property @{matchPattern=(&quot;*zdump*&quot;,&quot;*.xml&quot;,&quot;*.vmsn&quot;,&quot;*.vmsd&quot;,&quot;*.vswp*&quot;, &quot;*.vmx&quot;,&quot;*.vmdk&quot;,&quot;*.vmss&quot;,&quot;*.nvram&quot;,&quot;*.vmxf&quot;); details=(New-Object VMware.Vim.FileQueryFlags -property @{filesize=$true;modification=$true})}))})|?{$_.file})){foreach ($files in $ds.file){$files|?{$_.Path -notmatch &quot;-ctk.vmdk|esxconsole.vmdk|esxconsole-flat.vmdk&quot;}|select @{n=&quot;path&quot;;e={$ds.FolderPath + $files.path|%{$_ -replace &quot; &quot;,&quot;&quot;}}},FileSize,Modification|?{$_.path -notmatch &quot;.zfs|.snapshot|var/tmp/cache|/hostCache/|.lck&quot;}}}) $(get-view -ViewType virtualmachine|?{$_.Runtime.ConnectionState -notmatch &quot;invalid|orphaned&quot;}|%{$_.layoutex.file}|?{$_.type -ne &quot;log&quot;}|%{$_.name}|%{$_ -replace &quot; &quot;,&quot;&quot;}|sort -unique|select @{n=&quot;path&quot;;e={$_}})|?{$_.SideIndicator -eq &quot;&lt;=&quot;}|select @{n=&quot;LostFile&quot;;e={$_.Path -replace &quot;]&quot;,&quot;] &quot;}}, @{n=&quot;FileSize&quot;;e={&quot;{0:N0}&quot; -f ($_.FileSize/1MB)}}, Modification|?{$_.lostfile -match &quot;vswp&quot;})){(get-view (Get-View ServiceInstance|select -first 1).content.filemanager|select -first 1).DeleteDatastoreFile($lost.LostFile,(Get-View -ViewType datacenter|?{$_.Datastore -match (get-datastore $lost.LostFile.split(&quot;[]&quot;)[1]|get-view).moref}|select -first 1).moref)}</pre>
<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 24/02/2012</span> : Mise à jour du script pour afficher la taille en <strong>MegaBytes</strong> et la date de modification des fichiers.</em></p>
<p style="text-align: justify;">Très fortement inspiré du célèbre <a href="http://www.lucd.info/2011/08/11/vmx-raiders-revisited/" target="_blank">Raiders of the Lost VMX</a> (mais aussi du post <a href="http://www.lucd.info/2011/04/25/orphaned-files-and-folders-spring-cleaning/" target="_blank">Orphaned files and folders – Spring cleaning</a>) de LucD, nous avons enfin fini de finioler un oneliner PowerCLI qui va vous <strong>lister les fichiers .xml, .vmsn, .vmsd, .vswp, .vmx, .vmdk, .vmss, .nvram et .vmxf qui traînent sur vos datastores</strong> et qui ne sont pas rattachés à une quelconque vm du vcenter depuis lequel vous avez exécuté le script.</p>
<pre class="brush: powershell; title: ; notranslate">compare -passthru -property path $(foreach ($ds in ((get-view -ViewType datastore|sort name -unique|?{$_.summary.accessible}|%{(get-view $_.browser).SearchDatastoreSubFolders($(&quot;[&quot; + $_.Name + &quot;]&quot;),(New-Object VMware.Vim.HostDatastoreBrowserSearchSpec -property @{matchPattern=(&quot;*zdump*&quot;,&quot;*.xml&quot;,&quot;*.vmsn&quot;,&quot;*.vmsd&quot;,&quot;*.vswp*&quot;, &quot;*.vmx&quot;,&quot;*.vmdk&quot;,&quot;*.vmss&quot;,&quot;*.nvram&quot;,&quot;*.vmxf&quot;); details=(New-Object VMware.Vim.FileQueryFlags -property @{filesize=$true;modification=$true})}))})|?{$_.file})){foreach ($files in $ds.file){$files|?{$_.Path -notmatch &quot;-ctk.vmdk|esxconsole.vmdk|esxconsole-flat.vmdk&quot;}|select @{n=&quot;path&quot;;e={$ds.FolderPath + $files.path|%{$_ -replace &quot; &quot;,&quot;&quot;}}},FileSize,Modification|?{$_.path -notmatch &quot;.zfs|.snapshot|var/tmp/cache|/hostCache/|.lck&quot;}}}) $(get-view -ViewType virtualmachine|?{$_.Runtime.ConnectionState -notmatch &quot;invalid|orphaned&quot;}|%{$_.layoutex.file}|?{$_.type -ne &quot;log&quot;}|%{$_.name}|%{$_ -replace &quot; &quot;,&quot;&quot;}|sort -unique|select @{n=&quot;path&quot;;e={$_}})|?{$_.SideIndicator -eq &quot;&lt;=&quot;}|select @{n=&quot;LostFile&quot;;e={$_.Path -replace &quot;]&quot;,&quot;] &quot;}}, @{n=&quot;FileSize&quot;;e={&quot;{0:N0}&quot; -f ($_.FileSize/1MB)}}, Modification|ft -autosize</pre>
<p style="text-align: justify;">Les snapshots ZFS (.zfs/snapshot), les fichiers -ctk.vmdk (fichiers CBT) et les vmdk des COS d&#8217;ESX classic (esxconsole-) sont filtrés, n&#8217;hésitez pas à nous remonter d&#8217;autres faux positifs que vous pourriez rencontrer. <span style="text-decoration: line-through;">Prochaine étape : ménage automatique&#8230;</span></p>
<p style="text-align: center;"><a href="http://files.hypervisor.fr/img/lostvmfile_full.png" target="_blank"><img class="aligncenter" src="http://files.hypervisor.fr/img/lostvmfiles.png" alt="" width="521" height="287" /></a></p>
<p style="text-align: center;"><a href="http://files.hypervisor.fr/img/lostvmfilesize.png" target="_blank"><img class="aligncenter" src="http://files.hypervisor.fr/img/lostvmfilesize.png" alt="" width="504" height="125" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=3612</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>[PSH] DasConfigInfo.HostMonitoring en OneLiner</title>
		<link>http://www.hypervisor.fr/?p=3328</link>
		<comments>http://www.hypervisor.fr/?p=3328#comments</comments>
		<pubDate>Tue, 27 Sep 2011 15:19:09 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[HA]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=3328</guid>
		<description><![CDATA[En vue d&#8217;une maintenance réseau, vous pourrez être amené à désactiver la fonction HostMonitoring d&#8217;HA comme le recommande VMware :
When making changes to the networks that your clustered ESX/ESXi hosts are on, VMware recommends that you suspend the Host Monitoring feature.
Nous vous recommandons pour cela notre petit OneLiner PowerCLI maison :

Get-View -ViewType ClusterComputeResource&#124;%&#123;$_.ReconfigureComputeResource_Task&#40;&#40;New-Object VMware.Vim.ClusterConfigSpecEx -Property @&#123;DasConfig=&#40;New-Object VMware.Vim.ClusterDasConfigInfo -Property @&#123;HostMonitoring=&#34;disabled&#34;&#125;&#41;&#125;&#41;, $true&#41;&#125;

Vous trouverez [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">En vue d&#8217;une maintenance réseau, vous pourrez être amené à désactiver la fonction HostMonitoring d&#8217;HA <a href="http://pubs.vmware.com/vsphere-esx-4-1/availability_guide/c_customha_bestprac_net.html" target="_blank">comme le recommande VMware</a> :</p>
<blockquote><p>When making changes to the networks that your clustered ESX/ESXi hosts are on, VMware recommends that you suspend the Host Monitoring feature.</p></blockquote>
<p style="text-align: justify;">Nous vous recommandons pour cela notre petit OneLiner PowerCLI maison :</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">Get<span style="color: pink;">-</span>View <span style="color: pink;">-</span>ViewType ClusterComputeResource<span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.ReconfigureComputeResource_Task<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.ClusterConfigSpecEx <span style="color: #008080; font-style: italic;">-Property</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>DasConfig<span style="color: pink;">=</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.ClusterDasConfigInfo <span style="color: #008080; font-style: italic;">-Property</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>HostMonitoring<span style="color: pink;">=</span><span style="color: #800000;">&quot;disabled&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: pink;">,</span> <span style="color: #800080;">$true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span></pre></div></div>

<p>Vous trouverez facilement la commande inverse <img src='http://www.hypervisor.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=3328</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[PSH] Reactivation du copier/coller en OneLiner &#8211; MAJ</title>
		<link>http://www.hypervisor.fr/?p=3316</link>
		<comments>http://www.hypervisor.fr/?p=3316#comments</comments>
		<pubDate>Tue, 13 Sep 2011 18:00:18 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[VMTools]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=3316</guid>
		<description><![CDATA[MAJ 22/05/2015 : modification du script pour filtrer les vm connectées.
MAJ 23/04/2012 : modification du script pour filtrer les vm ayant déjà le bon paramétrage.
Comme l&#8217;indique cette kb, à partir d&#8217;ESX 4.1 le copier/coller via la console vmrc est désactivé pour des raisons de sécurité :
Starting with vSphere 4.1, the Copy and Paste options are, by default, disabled [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 22/05/2015</span> : modification du script pour filtrer les vm connectées.</em></p>
<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 23/04/2012</span> : modification du script pour filtrer les vm ayant déjà le bon paramétrage.</em></p>
<p style="text-align: justify;"><a href="http://kb.vmware.com/kb/1026437" target="_blank">Comme l&#8217;indique cette kb</a>, à partir d&#8217;ESX 4.1 le copier/coller via la console vmrc est désactivé pour des raisons de sécurité :</p>
<blockquote><p>Starting with vSphere 4.1, the Copy and Paste options are, by default, disabled for security reasons.</p>
<p>Note: This functionality was enabled by default in earlier releases of vSphere.</p></blockquote>
<p style="text-align: justify;">Pour le réactiver en GUI il faut impérativement arrêter la VM ce qui est évidement inacceptable. <a href="http://professionalvmware.com/2009/11/disabling-copy-paste-the-powercli-way/" target="_blank">En PowerCLI c&#8217;est très facile</a> mais en OneLiner, grâce au concours de notre cher <a href="http://www.vmdude.fr/" target="_blank">vmDude</a>, c&#8217;est nettement plus fun :</p>
<pre class="brush: powershell; title: ; notranslate">Get-View -ViewType VirtualMachine|?{$_.runtime.ConnectionState -eq &quot;connected&quot;}|?{-not $_.Config.Template}|?{!($_.Config.ExtraConfig|?{$_.key -match &quot;isolation.tools.paste.disable&quot; -or $_.key -match &quot;isolation.tools.copy.disable&quot;}) -or ($_.Config.ExtraConfig|?{($_.key -match &quot;isolation.tools.copy.disable&quot; -and $_.value -ne &quot;false&quot;) -or ($_.key-match &quot;isolation.tools.paste.disable&quot; -and $_.value -ne &quot;false&quot;)})}|%{$_.ReconfigVM((New-Object VMware.Vim.VirtualMachineConfigSpec -Property @{extraconfig=@((New-Object VMware.Vim.optionvalue -Property @{Key=&quot;isolation.tools.copy.disable&quot;;Value=&quot;$false&quot;});(New-Object VMware.Vim.optionvalue -Property @{Key=&quot;isolation.tools.paste.disable&quot;;Value=&quot;$false&quot;}))}))}</pre>
<p style="text-align: justify;">Cette commande agira d&#8217;un coup sur toutes les vm pour les fonctions &#8220;copier&#8221; et &#8220;coller&#8221;, il ne vous restera plus qu&#8217;à utiliser notre autre OneLiner <a href="http://www.hypervisor.fr/?p=3235" target="_blank">Shake My VM</a> pour effectuer un vmotion afin d&#8217;appliquer les modifications, ou d&#8217;attendre que DRS fasse le travail pour vous&#8230;</p>
<p style="text-align: justify;"><img class="aligncenter" src="http://www.hypervisor.fr/wp-content/uploads/2009/05/pcli_256x.png" alt="" width="128" height="128" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=3316</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>[PSH] Shake My VM</title>
		<link>http://www.hypervisor.fr/?p=3235</link>
		<comments>http://www.hypervisor.fr/?p=3235#comments</comments>
		<pubDate>Tue, 16 Aug 2011 22:39:13 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[DRS]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[VMotion]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=3235</guid>
		<description><![CDATA[Pour appliquer à chaud des settings comme un changement de VMM ou de swapfile, l&#8217;idéal c&#8217;est un bon vieux vmotion (grâce au &#8220;Power-on VM on destination host&#8220;). Le problème c&#8217;est que sur un cluster, le plus simple est de mettre les ESX en maintenance mode à tour de rôle mais c&#8217;est aussi le plus pénible ! [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Pour appliquer à chaud des settings comme <a href="http://www.hypervisor.fr/?p=1879">un changement de VMM</a> ou de <a href="http://www.hypervisor.fr/?p=2970">swapfile</a>, l&#8217;idéal c&#8217;est un bon vieux vmotion (grâce au &#8220;<a href="http://mylearn.vmware.com/courseware/26123/TA1405.PDF" target="_blank">Power-on VM on destination host</a>&#8220;). Le problème c&#8217;est que sur un cluster, le plus simple est de mettre les ESX en maintenance mode à tour de rôle mais c&#8217;est aussi le plus pénible ! Le top c&#8217;est un petit OneLiner de derrière les fagots qui va &#8220;secouer&#8221; vos VM :</p>
<pre class="brush: powershell; title: ; notranslate">get-vm|?{$_.PowerState -eq &quot;PoweredOn&quot;}|%{move-vm -vm $_ -destination (get-random @((($vmhost = $_.Vmhost).Parent|get-view).host|%{get-view $_}|?{$_.Runtime.ConnectionState -eq &quot;connected&quot; -and !$_.Runtime.InMaintenanceMode -and $_.Runtime.StandbyMode -eq &quot;none&quot; -and $_.name -cne $vmhost.name})).name -whatif}</pre>
<p style="text-align: justify;">Pour être un peu plus précis, ce script va faire un vmotion sur un des autres ESX disponibles du cluster parent. OneLiner oblige, ce script ne tient pas compte des vm qui seraient déplacées par DRS avant son passage. Il est par contre nécessaire d&#8217;avoir un minimum de &#8220;mou&#8221; sur le cluster en question pour éviter une vilaine contention.</p>
<p style="text-align: justify;">Dans l&#8217;état, le script vous affichera la liste des vmotion, il suffit d&#8217;ôter le &#8220;-whatif&#8221; et relancer pour agiter la pulpe <img src='http://www.hypervisor.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: justify;"><img class="aligncenter" src="http://files.hypervisor.fr/img/logo_orangina_rouge.jpg" alt="" width="213" height="213" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=3235</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[PSH] AutoDetect Display Memory en OneLiner</title>
		<link>http://www.hypervisor.fr/?p=3024</link>
		<comments>http://www.hypervisor.fr/?p=3024#comments</comments>
		<pubDate>Wed, 01 Jun 2011 00:28:19 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=3024</guid>
		<description><![CDATA[Juste pour le sport, voici la version oneliner du script d&#8217;Alan permettant de fixer la taille de la mémoire vidéo des VM à AutoDetect pour éviter les warnings lors de vmotion :
Insufficient video RAM. The maximum resolution of the virtual machine will be limited to 1176&#215;885. To use the configured maximum resolution of 2560&#215;1600, increase the amount of video [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Juste pour le sport, voici la version oneliner <a href="http://www.virtu-al.net/2011/03/10/change-vm-video-memory/" target="_blank">du script d&#8217;Alan permettant de fixer la taille de la mémoire vidéo des VM à AutoDetect</a> pour éviter les warnings lors de vmotion :</p>
<blockquote><p>Insufficient video RAM. The maximum resolution of the virtual machine will be limited to 1176&#215;885. To use the configured maximum resolution of 2560&#215;1600, increase the amount of video RAM allocated to this virtual machine by setting svga.vramSize=&#8221;16384000&#8243; in the virtual machine&#8217;s configuration file</p></blockquote>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">Get<span style="color: pink;">-</span>VM<span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#40;</span><span style="color: #000080;">$_</span>.ExtensionData.Config.Hardware.Device<span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.GetType<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.Name <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;VirtualMachineVideoCard&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>.useAutoDetect <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$false</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#40;</span><span style="color: #000080;">$_</span><span style="color: pink;">|</span>Get<span style="color: pink;">-</span>View<span style="color: #000000;">&#41;</span>.ReconfigVM<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.VirtualMachineConfigSpec <span style="color: #008080; font-style: italic;">-Property</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>DeviceChange<span style="color: pink;">=</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.VirtualDeviceConfigSpec <span style="color: #008080; font-style: italic;">-Property</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>Operation<span style="color: pink;">=</span><span style="color: #800000;">&quot;edit&quot;</span>;Device<span style="color: pink;">=</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.VirtualMachineVideoCard <span style="color: #008080; font-style: italic;">-Property</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>UseAutoDetect<span style="color: pink;">=</span><span style="color: #800000;">&quot;$true&quot;</span>;Key<span style="color: pink;">=</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000080;">$_</span>.ExtensionData.Config.Hardware.Device<span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.GetType<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.Name <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;VirtualMachineVideoCard&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>.key<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span></pre></div></div>

<p style="text-align: justify;">Et vous pouvez l’exécuter 10x de suite, elle n&#8217;agira que sur les VM qui ne sont pas en auto <img src='http://www.hypervisor.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=3024</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>[PSH] OneLiner pour activer Storage IO Control &#8211; MAJ</title>
		<link>http://www.hypervisor.fr/?p=3014</link>
		<comments>http://www.hypervisor.fr/?p=3014#comments</comments>
		<pubDate>Sun, 29 May 2011 22:33:20 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[Kb]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[IORM]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[SIOC]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=3014</guid>
		<description><![CDATA[MAJ 21/12/2011 : Rajout des filtres &#8220;Accessible&#8221; et &#8220;IormConfiguration.Enabled&#8221;
MAJ 01/06/2011 : Rajout du filtre &#8220;MultipleHostAccess&#8221; pour éviter l&#8217;activation de SIOC sur du DAS
Si vous devez activer Storage I/O Control (aka IORM) sur les datastores d&#8217;un cluster, vous ne sauriez opérer autrement qu&#8217;avec un bon script ou mieux, avec un petit oneliner bien mijoté (et comme souvent, inspiré d&#8217;un post [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 21/12/2011</span> : Rajout des filtres &#8220;Accessible&#8221; et &#8220;IormConfiguration.Enabled&#8221;</em></p>
<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 01/06/2011</span> : Rajout du filtre &#8220;MultipleHostAccess&#8221; pour éviter l&#8217;activation de SIOC sur du DAS</em></p>
<p style="text-align: justify;">Si vous devez activer <a href="http://www.vmware.com/files/pdf/techpaper/VMW-vSphere41-SIOC.pdf" target="_blank">Storage I/O Control</a> (aka IORM) sur les datastores d&#8217;un cluster, vous ne sauriez opérer autrement qu&#8217;avec un bon script ou mieux, avec un petit oneliner bien mijoté (et comme souvent, <a href="http://www.lucd.info/2010/10/20/automate-sioc/" target="_blank">inspiré d&#8217;un post de Luc</a>) :</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">Get<span style="color: pink;">-</span>VMHost <span style="color: pink;">-</span>location <span style="color: #800000;">&quot;MonBeauCluster&quot;</span><span style="color: pink;">|</span>Get<span style="color: pink;">-</span>Datastore<span style="color: pink;">|</span>Get<span style="color: pink;">-</span>View<span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Summary.Accessible <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$true</span> <span style="color: #FF0000;">-and</span> <span style="color: #000080;">$_</span>.Capability.StorageIORMSupported <span style="color: #FF0000;">-and</span> <span style="color: #000080;">$_</span>.Summary.MultipleHostAccess <span style="color: #FF0000;">-and</span> <span style="color: #000080;">$_</span>.IormConfiguration.Enabled <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$true</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>View <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>View ServiceInstance<span style="color: #000000;">&#41;</span>.Content.StorageResourceManager<span style="color: #000000;">&#41;</span>.ConfigureDatastoreIORM_Task<span style="color: #000000;">&#40;</span><span style="color: #000080;">$_</span>.MoRef<span style="color: pink;">,</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">New-Object</span> VMware.Vim.StorageIORMConfigSpec <span style="color: #008080; font-style: italic;">-Property</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>enabled<span style="color: pink;">=</span><span style="color: #800000;">&quot;1&quot;</span>;congestionThreshold<span style="color: pink;">=</span><span style="color: #800000;">&quot;25&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span></pre></div></div>

<p style="text-align: justify;">La valeur par défaut de la variable <strong>congestionThreshold </strong>est &#8220;30&#8243; mais peut être tuné en fonction de la nature du stockage (fixée à &#8220;25&#8243; dans notre oneliner), comme détaillé dans le pdf linké en début de post.</p>
<p style="text-align: justify;">Et pour ceux que ça intéresse, la kb <a href="http://kb.vmware.com/kb/1022091" target="_blank">Troubleshooting Storage I/O Control</a> précise quelques points importants (ainsi que le la façon d&#8217;obtenir les logs de SIOC) :</p>
<ul>
<li>Before enabling SIOC, ensure that datastores are managed by a single vCenter Server.</li>
<li>[...] <strong>if the number of hosts connected to the datastore has changed since enabling SIOC</strong> [...]</li>
</ul>
<p style="text-align: center;"><a href="http://www.vmware.com/products/storage-io-control/overview.html"><img class="aligncenter" src="http://www.vmware.com/files/images/storageio-diagram-large.jpg" alt="" width="384" height="288" /></a></p>
<p style="text-align: left;">Et pour ceux qui veulent savoir comment ça marche, direction les sessions Technology and Architecture du vmworld 2010 : <a href="http://www.vmworld.com/docs/DOC-5117" target="_blank">Prioritizing Storage Resource Allocation in ESX Based Virtual Environments Using Storage I/O Control</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=3014</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>[PSH] Swap Placement par Resource Pool en OneLiner</title>
		<link>http://www.hypervisor.fr/?p=2970</link>
		<comments>http://www.hypervisor.fr/?p=2970#comments</comments>
		<pubDate>Thu, 05 May 2011 00:09:42 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[swap]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=2970</guid>
		<description><![CDATA[Voici un petit oneliner (inspiré d&#8217;un post de LucD) qui vous permettra de changer la politique de placement du fichier swap des VM membres des resource pool dont le nom contient le mot &#8220;qualif&#8221; :
Get-View -ViewType ResourcePool&#124;?{$_.name -match &#34;qualif&#34;}&#124;?{$_.Vm.count -gt 0}&#124;%{(Get-View $_.vm)&#124;?{$_.Config.SwapPlacement -ne &#34;vmDirectory&#34;}&#124;%{$_.ReconfigVM((New-Object VMware.Vim.VirtualMachineConfigSpec -Property @{SwapPlacement=&#34;vmDirectory&#34;}))}}
Dans notre cas, pour économiser l&#8217;espace disque sur notre [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Voici un petit oneliner (<a href="http://communities.vmware.com/message/1716961#1716961" target="_blank">inspiré d&#8217;un post de LucD</a>) qui vous permettra de <strong>changer la politique de placement du fichier swap des VM membres des resource pool dont le nom contient le mot &#8220;qualif&#8221; :</strong></p>
<pre class="brush: powershell; title: ; notranslate">Get-View -ViewType ResourcePool|?{$_.name -match &quot;qualif&quot;}|?{$_.Vm.count -gt 0}|%{(Get-View $_.vm)|?{$_.Config.SwapPlacement -ne &quot;vmDirectory&quot;}|%{$_.ReconfigVM((New-Object VMware.Vim.VirtualMachineConfigSpec -Property @{SwapPlacement=&quot;vmDirectory&quot;}))}}</pre>
<p style="text-align: justify;">Dans notre cas, pour économiser l&#8217;espace disque sur notre SAN, les fichiers .vswp sont redirigés sur les disques locaux des ESX mais la consolidation allant bon train nous nous sommes retrouvés dans une situation où l&#8217;espace disque local n&#8217;est plus suffisant. Les VM membres des resource pool de qualif/test/dev étant stockées sur des partages NFS, nous avons pris la décision de bypasser la politique pour ces dernières et de laisser le fichier dans le répertoire de la vm.</p>
<p style="text-align: justify;">Par contre, n&#8217;oubliez pas que sur du stockage &#8220;thin provisioné&#8221; l&#8217;espace du fichier de swap n&#8217;étant pas reservé, l&#8217;admition control est faussé. Mais j’espère pour vous que n&#8217;en êtes pas au point de remplir les fichiers swap de vos VM (<a href="http://communities.vmware.com/blogs/chethank/2009/12/22/using-solidstate-drives-to-improve-performance-of-sql-databases-on-vsphere-hosts-when-memory-is-overcommitted" target="_blank">même si un jour cela pourrai devenir une option grâce aux SSD</a>) <img src='http://www.hypervisor.fr/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p style="text-align: center;"><img class="aligncenter" src="http://www.canardpc.com/img/news/31025/imft_43622_6727.jpg" alt="" width="222" height="177" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=2970</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[PSH] Export/Import des Custom Attributes</title>
		<link>http://www.hypervisor.fr/?p=2927</link>
		<comments>http://www.hypervisor.fr/?p=2927#comments</comments>
		<pubDate>Thu, 28 Apr 2011 17:07:46 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=2927</guid>
		<description><![CDATA[Lors d&#8217;une restore de VM ou suite à une mauvaise manipulation, il peut arriver de perdre les précieux &#8221;Custom Attributes&#8221; aka &#8220;Custom Fields&#8221; qui sont stockés dans la base du vCenter et non dans le vmx de la vm comme c&#8217;est le cas de l&#8217;attribut &#8220;annotation&#8221; aka &#8220;notes&#8221; aka &#8220;Description&#8221; (oui, nous aussi ça nous gonfle&#8230;) :

C&#8217;est encore PowerCLI [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Lors d&#8217;une restore de VM ou suite à une mauvaise manipulation, il peut arriver de perdre les précieux &#8221;Custom Attributes&#8221; aka &#8220;<strong>Custom Fields</strong>&#8221; qui sont stockés dans la base du vCenter et non dans le vmx de la vm comme c&#8217;est le cas de l&#8217;attribut &#8220;<strong>annotation</strong>&#8221; aka &#8220;notes&#8221; aka &#8220;Description&#8221; (oui, nous aussi ça nous gonfle&#8230;) :</p>
<p><img class="aligncenter" src="http://files.hypervisor.fr/img/FieldsExport/Annotations.png" alt="" width="352" height="190" /></p>
<p style="text-align: justify;">C&#8217;est encore <strong>PowerCLI </strong>qui vient à notre secours pour un script d&#8217;export/import de ces informations vers un fichier xml pour une manipulation plus facile.</p>
<p style="text-align: justify;">Sans arguments, le script exportera <strong>l&#8217;ensemble des Custom Fields et Annotation de toutes les vm</strong> (ou d&#8217;une en particulier grâce au paramètre -VmAlone)  dans un fichier &#8220;VmFieldList.xml&#8221; dans le répertoire courant (ou à l&#8217;emplacement de votre choix grâce au parametre -$XmlPath) ; si le fichier existe déjà, il sera renommé suivant la nomenclature VmFieldList-yyyyMMddHHmmss.xml. Le fichier généré ressemble à cela :</p>
<p style="text-align: center;"><a href="http://files.hypervisor.fr/img/FieldsExport/export.png"><img class="aligncenter" src="http://files.hypervisor.fr/img/FieldsExport/export.png" alt="" width="316" height="277" /></a></p>
<p style="text-align: left;">Pour restaurer les infos d&#8217;une VM, voici la syntaxe :</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">IOCustomField.ps1 <span style="color: pink;">-</span>VmAlone RSW2K8VPX51 <span style="color: pink;">-</span>Action import <span style="color: #008080; font-style: italic;">-Confirm</span> <span style="color: #804000;">1</span></pre></div></div>

<p style="text-align: justify;">Pour restaurer toute ou une partie des vm, il suffit de passer au script le nom de la vm dans une boucle :</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">Get<span style="color: pink;">-</span>Cluster <span style="color: #800000;">&quot;CLU01&quot;</span><span style="color: pink;">|</span>Get<span style="color: pink;">-</span>VM<span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span>.\IOCustomField.ps1 <span style="color: pink;">-</span>VmAlone <span style="color: #000080;">$_</span>.name <span style="color: pink;">-</span>Action import <span style="color: #008080; font-style: italic;">-Confirm</span> <span style="color: #804000;">1</span> <span style="color: pink;">-</span>XmlPath .\VmFieldList.xml<span style="color: #000000;">&#125;</span></pre></div></div>

<div class="wp-caption aligncenter" style="width: 85px"><a href="http://files.hypervisor.fr/scripts/IOCustomFields.ps1"><img title="IOCustomFields.ps1" src="http://files.hypervisor.fr/img/download_icon_300.png" alt="" width="75" height="64" /></a><p class="wp-caption-text">download</p></div>
<p style="text-align: left;">En bonus, un petit OneLiner pour <strong>exporter vos Host Profiles</strong> en fichiers .prf du même nom :</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">Get<span style="color: pink;">-</span>VMHostProfile<span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span>Export<span style="color: pink;">-</span>VMHostProfile <span style="color: #008080; font-style: italic;">-FilePath</span> <span style="color: #800000;">&quot;$($_.name).vpf&quot;</span> <span style="color: pink;">-</span>Profile <span style="color: #000080;">$_</span> <span style="color: #008080; font-style: italic;">-Force</span><span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=2927</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[PSH] unmount global d&#8217;un datastore NFS &#8211; MAJ</title>
		<link>http://www.hypervisor.fr/?p=2713</link>
		<comments>http://www.hypervisor.fr/?p=2713#comments</comments>
		<pubDate>Wed, 09 Mar 2011 22:42:51 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=2713</guid>
		<description><![CDATA[MAJ 12/03/2011 : Ofer Bezalel nous a suggéré une méthode optimisé :

&#40;get-datastore datastore&#41;.extensiondata.host&#124;%&#123;&#40;get-view &#40;get-view $_.key&#41;.ConfigManager.DatastoreSystem&#41;.RemoveDatastore&#40;&#40;get-datastore datastore&#41;.extensiondata.moref&#41;&#125;

Voici un petit oneliner qui démontera le datastore désigné de tous les ESX sur lesquels il était monté :

&#40;Get-Datastore datastore&#124;get-view&#41;.host&#124;%&#123;&#40;get-view &#40;get-view $_.key&#41;.ConfigManager.DatastoreSystem&#41;.RemoveDatastore&#40;&#40;Get-Datastore datastore&#124;get-view&#41;.moref&#41;&#125;

A grande échelle c&#8217;est pratique !

]]></description>
			<content:encoded><![CDATA[<p><em><span style="color: #ff0000;">MAJ 12/03/2011</span> : <a href="http://twitter.com/#!/oferbezalel/status/45960110635352064" target="_blank">Ofer Bezalel nous a suggéré</a> une méthode optimisé :</em></p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #000000;">&#40;</span>get<span style="color: pink;">-</span>datastore datastore<span style="color: #000000;">&#41;</span>.extensiondata.host<span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#40;</span>get<span style="color: pink;">-</span>view <span style="color: #000000;">&#40;</span>get<span style="color: pink;">-</span>view <span style="color: #000080;">$_</span>.key<span style="color: #000000;">&#41;</span>.ConfigManager.DatastoreSystem<span style="color: #000000;">&#41;</span>.RemoveDatastore<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>get<span style="color: pink;">-</span>datastore datastore<span style="color: #000000;">&#41;</span>.extensiondata.moref<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span></pre></div></div>

<p>Voici un petit oneliner qui démontera le datastore désigné de tous les ESX sur lesquels il était monté :</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>Datastore datastore<span style="color: pink;">|</span>get<span style="color: pink;">-</span>view<span style="color: #000000;">&#41;</span>.host<span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#40;</span>get<span style="color: pink;">-</span>view <span style="color: #000000;">&#40;</span>get<span style="color: pink;">-</span>view <span style="color: #000080;">$_</span>.key<span style="color: #000000;">&#41;</span>.ConfigManager.DatastoreSystem<span style="color: #000000;">&#41;</span>.RemoveDatastore<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>Datastore datastore<span style="color: pink;">|</span>get<span style="color: pink;">-</span>view<span style="color: #000000;">&#41;</span>.moref<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span></pre></div></div>

<p>A grande échelle c&#8217;est pratique !</p>
<p style="text-align: center;"><img class="aligncenter" src="http://hypervisor.free.fr/img/remove-nfs.png" alt="" width="312" height="377" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=2713</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[PSH] Liste des WorldWideName</title>
		<link>http://www.hypervisor.fr/?p=2703</link>
		<comments>http://www.hypervisor.fr/?p=2703#comments</comments>
		<pubDate>Fri, 25 Feb 2011 00:50:16 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[VMware]]></category>
		<category><![CDATA[HBA]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[vmhba]]></category>
		<category><![CDATA[WWN]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=2703</guid>
		<description><![CDATA[Tout pareil que notre confrère cloudydude.fr vmdude.fr, des fois nous avons besoin de la liste des WWN par host ou par cluster. Sauf que nous on fait dans le dirty oneliner :

get-vmhost -location &#34;mon_beau_cluster&#34;&#124;get-view&#124;select name,@&#123;N=&#34;WWN&#34;;E=&#123;get-view $_.ConfigManager.StorageSystem&#124;%&#123;$_.StorageDeviceInfo.HostBusAdapter&#124;?&#123;$_ -is &#91;VMware.Vim.HostFibreChannelHba&#93;&#125;&#125;&#124;select @&#123;N=&#34;WWN&#34;;E=&#123;&#34;{0:x}&#34; -f $_.PortWorldWideName&#125;&#125;&#125;&#125;&#124;select name -ExpandProperty WWN&#124;select name, @&#123;N=&#34;WWN&#34;;E=&#123;$_.WWN.substring&#40;0,2&#41;+&#34;:&#34;+$_.WWN.substring&#40;2,2&#41;+&#34;:&#34;+$_.WWN.substring&#40;4,2&#41;+&#34;:&#34;+$_.WWN.substring&#40;6,2&#41;+&#34;:&#34;+$_.WWN.substring&#40;8,2&#41;+&#34;:&#34;+$_.WWN.substring&#40;10,2&#41;+&#34;:&#34;+$_.WWN.substring&#40;12,2&#41;+&#34;:&#34;+$_.WWN.substring&#40;14,2&#41;&#125;&#125;&#124;sort name


PS : Et nous on pense que les &#8220;:&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Tout pareil que notre confrère <del datetime="2011-02-25T08:13:22+00:00">cloudydude.fr</del> <a href="http://www.vmdude.fr">vmdude.fr</a>, <a href="http://www.vmdude.fr/scripts/oh-mon-wwn-ou-es-tu/" target="_blank">des fois nous avons besoin de la liste des WWN</a> par host ou par cluster. Sauf que nous on fait dans le dirty oneliner :</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">get<span style="color: pink;">-</span>vmhost <span style="color: pink;">-</span>location <span style="color: #800000;">&quot;mon_beau_cluster&quot;</span><span style="color: pink;">|</span>get<span style="color: pink;">-</span>view<span style="color: pink;">|</span>select name<span style="color: pink;">,@</span><span style="color: #000000;">&#123;</span>N<span style="color: pink;">=</span><span style="color: #800000;">&quot;WWN&quot;</span>;E<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span>get<span style="color: pink;">-</span>view <span style="color: #000080;">$_</span>.ConfigManager.StorageSystem<span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.StorageDeviceInfo.HostBusAdapter<span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span> <span style="color: #FF0000;">-is</span> <span style="color: #000000;">&#91;</span>VMware.Vim.HostFibreChannelHba<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|</span>select <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>N<span style="color: pink;">=</span><span style="color: #800000;">&quot;WWN&quot;</span>;E<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span><span style="color: #800000;">&quot;{0:x}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #000080;">$_</span>.PortWorldWideName<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|</span>select name <span style="color: #008080; font-style: italic;">-ExpandProperty</span> WWN<span style="color: pink;">|</span>select name<span style="color: pink;">,</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>N<span style="color: pink;">=</span><span style="color: #800000;">&quot;WWN&quot;</span>;E<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.WWN.substring<span style="color: #000000;">&#40;</span><span style="color: #804000;">0</span><span style="color: pink;">,</span><span style="color: #804000;">2</span><span style="color: #000000;">&#41;</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: pink;">+</span><span style="color: #000080;">$_</span>.WWN.substring<span style="color: #000000;">&#40;</span><span style="color: #804000;">2</span><span style="color: pink;">,</span><span style="color: #804000;">2</span><span style="color: #000000;">&#41;</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: pink;">+</span><span style="color: #000080;">$_</span>.WWN.substring<span style="color: #000000;">&#40;</span><span style="color: #804000;">4</span><span style="color: pink;">,</span><span style="color: #804000;">2</span><span style="color: #000000;">&#41;</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: pink;">+</span><span style="color: #000080;">$_</span>.WWN.substring<span style="color: #000000;">&#40;</span><span style="color: #804000;">6</span><span style="color: pink;">,</span><span style="color: #804000;">2</span><span style="color: #000000;">&#41;</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: pink;">+</span><span style="color: #000080;">$_</span>.WWN.substring<span style="color: #000000;">&#40;</span><span style="color: #804000;">8</span><span style="color: pink;">,</span><span style="color: #804000;">2</span><span style="color: #000000;">&#41;</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: pink;">+</span><span style="color: #000080;">$_</span>.WWN.substring<span style="color: #000000;">&#40;</span><span style="color: #804000;">10</span><span style="color: pink;">,</span><span style="color: #804000;">2</span><span style="color: #000000;">&#41;</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: pink;">+</span><span style="color: #000080;">$_</span>.WWN.substring<span style="color: #000000;">&#40;</span><span style="color: #804000;">12</span><span style="color: pink;">,</span><span style="color: #804000;">2</span><span style="color: #000000;">&#41;</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: pink;">+</span><span style="color: #000080;">$_</span>.WWN.substring<span style="color: #000000;">&#40;</span><span style="color: #804000;">14</span><span style="color: pink;">,</span><span style="color: #804000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|</span>sort name</pre></div></div>

<p><img class="aligncenter" title="WWN" src="http://hypervisor.free.fr/img/wwn.png" alt="" width="492" height="356" /></p>
<p>PS : Et nous on pense que les &#8220;:&#8221; c&#8217;est important <img src='http://www.hypervisor.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=2703</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>[PSH] vmdk orphelins via oneliner</title>
		<link>http://www.hypervisor.fr/?p=2678</link>
		<comments>http://www.hypervisor.fr/?p=2678#comments</comments>
		<pubDate>Thu, 03 Feb 2011 00:34:10 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=2678</guid>
		<description><![CDATA[MAJ 31/03/2011 : Voici la commande modifiée pour n&#8217;avoir la visu que sur un seul datastore (désigné par la variable $ds) :

$ds = get-datastore &#34;NexentaStor&#34;;compare &#40;$ds&#124;?&#123;$_.Accessible -eq &#34;true&#34;&#125;&#124;Get-HardDisk&#41; &#40;Get-View -ViewType VirtualMachine&#124;?&#123;$_.datastore -match $ds.id&#125;&#124;?&#123;$_.Summary.Runtime.ConnectionState -eq &#34;Connected&#34;&#125;&#124;%&#123;$_.Layout&#125;&#124;%&#123;$_.Disk&#125;&#124;%&#123;$_.DiskFile&#125;&#124;select @&#123;N=&#34;filename&#34;;E=&#123;$_&#125;&#125;&#41; -property filename&#124;ft -AutoSize

Encore un petit oneliner PowerShell/PowerCLI à partager : trouver les vmdk orphelins sur vos datastore, y compris [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><em><span style="color: #ff0000;">MAJ 31/03/2011</span></em> : <em>Voici la commande modifiée pour n&#8217;avoir la visu que sur un seul datastore (désigné par la variable $ds)</em> :</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$ds</span> <span style="color: pink;">=</span> get<span style="color: pink;">-</span>datastore <span style="color: #800000;">&quot;NexentaStor&quot;</span>;compare <span style="color: #000000;">&#40;</span><span style="color: #800080;">$ds</span><span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Accessible <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;true&quot;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|</span>Get<span style="color: pink;">-</span>HardDisk<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>View <span style="color: pink;">-</span>ViewType VirtualMachine<span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.datastore <span style="color: #FF0000;">-match</span> <span style="color: #800080;">$ds</span>.id<span style="color: #000000;">&#125;</span><span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Summary.Runtime.ConnectionState <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;Connected&quot;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Layout<span style="color: #000000;">&#125;</span><span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Disk<span style="color: #000000;">&#125;</span><span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.DiskFile<span style="color: #000000;">&#125;</span><span style="color: pink;">|</span>select <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>N<span style="color: pink;">=</span><span style="color: #800000;">&quot;filename&quot;</span>;E<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">-property</span> filename<span style="color: pink;">|</span>ft <span style="color: #008080; font-style: italic;">-AutoSize</span></pre></div></div>

<p style="text-align: justify;">Encore un petit oneliner PowerShell/PowerCLI à partager : <strong>trouver les vmdk orphelins sur vos datastore</strong>, y compris les snapshots.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">compare <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>Datastore<span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Accessible <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;true&quot;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|</span>Get<span style="color: pink;">-</span>HardDisk<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>View <span style="color: pink;">-</span>ViewType VirtualMachine<span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Summary.Runtime.ConnectionState <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;Connected&quot;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Layout<span style="color: #000000;">&#125;</span><span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Disk<span style="color: #000000;">&#125;</span><span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.DiskFile<span style="color: #000000;">&#125;</span><span style="color: pink;">|</span>select <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>N<span style="color: pink;">=</span><span style="color: #800000;">&quot;filename&quot;</span>;E<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">-property</span> filename<span style="color: pink;">|</span>ft <span style="color: #008080; font-style: italic;">-AutoSize</span></pre></div></div>

<p>Résultat :</p>
<p><a href="http://hypervisor.free.fr/img/lost_vmdk.png" title="lost_vmdk" rel="lightbox[2678]"><img class="aligncenter size-full wp-image-2682" title="lost_vmdk" src="http://www.hypervisor.fr/wp-content/uploads/2011/02/lost_vmdk.png" alt="" width="491" height="118" /></a></p>
<p style="text-align: justify;">Le &#8220;SideIndicator&#8221; vous permet de savoir de quel &#8220;coté&#8221; le vmdk est manquant. Si c&#8217;est vers la droite (en jaune), c&#8217;est un vmdk qui n&#8217;existe plus sur le datastore mais encore dans le vcenter et si c&#8217;est vers la gauche (en rouge) c&#8217;est un vmdk qui n’appartient à aucune vm du vcenter.</p>
<p>Pour les vmx, nous vous recommandons le célèbre <a href="http://www.lucd.info/2009/12/02/raiders-of-the-lost-vmx/" target="_blank">Raiders of the Lost VMX de LucD</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=2678</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>[PSH] statistiques vmnic : the FatOneLiner</title>
		<link>http://www.hypervisor.fr/?p=2665</link>
		<comments>http://www.hypervisor.fr/?p=2665#comments</comments>
		<pubDate>Tue, 25 Jan 2011 23:46:58 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[VMware]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=2665</guid>
		<description><![CDATA[Pour la beauté de cette discipline mais aussi pour relever un défi personnel, voici un &#8220;petit&#8221; oneliner PowerCLI qui affichent les statistiques des vmnic des tous les ESX. La période est configurable en minutes grâce à la variable $delta en début de ligne (1-60), la colonne &#8220;speed&#8221; est la vitesse de connexion et les valeurs [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Pour la beauté de cette discipline mais aussi pour relever un défi personnel, voici un &#8220;petit&#8221; oneliner PowerCLI qui affichent <strong>les statistiques des vmnic des tous les ESX</strong>. La période est configurable en minutes grâce à la variable $delta en début de ligne (1-60), la colonne &#8220;speed&#8221; est la vitesse de connexion et les valeurs Inbound et Outbound sont exprimées en kB/s.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #800080;">$delta</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;5&quot;</span>;get<span style="color: pink;">-</span>view <span style="color: pink;">-</span>viewtype <span style="color: #800000;">&quot;hostsystem&quot;</span><span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Runtime.ConnectionState <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;Connected&quot;</span> <span style="color: #FF0000;">-or</span> <span style="color: #000080;">$_</span>.Runtime.ConnectionState <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;Maintenance&quot;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$esx</span><span style="color: pink;">=</span><span style="color: #000080;">$_</span>.name;<span style="color: #000080;">$_</span>.ConfigManager.NetworkSystem<span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span>get<span style="color: pink;">-</span>view <span style="color: #000080;">$_</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.NetworkInfo<span style="color: #000000;">&#125;</span><span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.pnic<span style="color: #000000;">&#125;</span><span style="color: pink;">|%</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$vmnic</span> <span style="color: pink;">=</span> <span style="color: #000080;">$_</span>.device;<span style="color: #000080;">$_</span><span style="color: pink;">|</span>select <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>N<span style="color: pink;">=</span><span style="color: #800000;">&quot;ESX&quot;</span>;E<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span><span style="color: #800080;">$esx</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">,@</span><span style="color: #000000;">&#123;</span>N<span style="color: pink;">=</span><span style="color: #800000;">&quot;vmnic&quot;</span>;E<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.device<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">,@</span><span style="color: #000000;">&#123;</span>N<span style="color: pink;">=</span><span style="color: #800000;">&quot;Speed&quot;</span>;E<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.linkspeed.SpeedMb<span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">,@</span><span style="color: #000000;">&#123;</span>N<span style="color: pink;">=</span><span style="color: #800000;">&quot;Inbound&quot;</span>;E<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#91;</span>math<span style="color: #000000;">&#93;</span>::round<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>get<span style="color: pink;">-</span>vmhost <span style="color: #800080;">$esx</span><span style="color: pink;">|</span>get<span style="color: pink;">-</span>stat <span style="color: pink;">-</span>Stat net.received.average <span style="color: pink;">-</span>Realtime<span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Timestamp <span style="color: #FF0000;">-gt</span> <span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">get-date</span><span style="color: #000000;">&#41;</span>.addminutes<span style="color: #000000;">&#40;</span><span style="color: pink;">-</span><span style="color: #800080;">$delta</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.instance <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$vmnic</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|</span>Measure<span style="color: pink;">-</span>Object <span style="color: #008080; font-style: italic;">-Property</span> Value <span style="color: #008080; font-style: italic;">-Average</span><span style="color: #000000;">&#41;</span>.average<span style="color: pink;">,</span><span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">,@</span><span style="color: #000000;">&#123;</span>N<span style="color: pink;">=</span><span style="color: #800000;">&quot;Outbound&quot;</span>;E<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#91;</span>math<span style="color: #000000;">&#93;</span>::round<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>get<span style="color: pink;">-</span>vmhost <span style="color: #800080;">$esx</span><span style="color: pink;">|</span>get<span style="color: pink;">-</span>stat <span style="color: pink;">-</span>Stat net.transmitted.average <span style="color: pink;">-</span>Realtime<span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Timestamp <span style="color: #FF0000;">-gt</span> <span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">get-date</span><span style="color: #000000;">&#41;</span>.addminutes<span style="color: #000000;">&#40;</span><span style="color: pink;">-</span><span style="color: #800080;">$delta</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|?</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.instance <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$vmnic</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|</span>Measure<span style="color: pink;">-</span>Object <span style="color: #008080; font-style: italic;">-Property</span> Value <span style="color: #008080; font-style: italic;">-Average</span><span style="color: #000000;">&#41;</span>.average<span style="color: pink;">,</span><span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">|</span>ft <span style="color: #008080; font-style: italic;">-AutoSize</span></pre></div></div>

<p>Et voila le résultat :</p>
<p><a href="http://hypervisor.free.fr/img/vmnic_stats.png" title="vmnic_stats" rel="lightbox[2665]"><img class="aligncenter size-full wp-image-2667" title="vmnic_stats" src="http://www.hypervisor.fr/wp-content/uploads/2011/01/vmnic_stats.png" alt="" width="518" height="336" /></a></p>
<p>Spécial cassedédie à papycloud <img src='http://www.hypervisor.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=2665</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Une journée de scripting #2</title>
		<link>http://www.hypervisor.fr/?p=1655</link>
		<comments>http://www.hypervisor.fr/?p=1655#comments</comments>
		<pubDate>Tue, 08 Dec 2009 12:20:16 +0000</pubDate>
		<dc:creator>NiTRo</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[oneliner]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://www.hypervisor.fr/?p=1655</guid>
		<description><![CDATA[Quelques commandes pratiques pour les CLI addict que nous sommes  

Get-Template &#34;template&#34; &#124;Set-Template -tovm
&#40;Get-View -ViewType VirtualMachine -Filter @&#123;&#34;Name&#34; = &#34;template&#34; &#125;&#41;.MarkAsTemplate&#40;&#41;

Ces 2 commandes permettent de changer un template en vm, puis de changer cette vm en template à nouveau. Cela permet d&#8217;éviter la GUI et ses questions inutiles&#8230;

get-vm -name VM1,VM2,VM3 &#124;New-Snapshot -name &#34;snapshot&#34; -description [...]]]></description>
			<content:encoded><![CDATA[<p>Quelques commandes pratiques pour les CLI addict que nous sommes <img src='http://www.hypervisor.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">Get<span style="color: pink;">-</span>Template <span style="color: #800000;">&quot;template&quot;</span> <span style="color: pink;">|</span>Set<span style="color: pink;">-</span>Template <span style="color: pink;">-</span>tovm
<span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>View <span style="color: pink;">-</span>ViewType VirtualMachine <span style="color: pink;">-</span><span style="color: #0000FF;">Filter</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span><span style="color: #800000;">&quot;Name&quot;</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;template&quot;</span> <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>.MarkAsTemplate<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></pre></div></div>

<p>Ces 2 commandes permettent de changer un template en vm, puis de changer cette vm en template à nouveau. Cela permet d&#8217;éviter la GUI et ses questions inutiles&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">get<span style="color: pink;">-</span>vm <span style="color: #008080; font-style: italic;">-name</span> VM1<span style="color: pink;">,</span>VM2<span style="color: pink;">,</span>VM3 <span style="color: pink;">|</span>New<span style="color: pink;">-</span>Snapshot <span style="color: #008080; font-style: italic;">-name</span> <span style="color: #800000;">&quot;snapshot&quot;</span> <span style="color: #008080; font-style: italic;">-description</span> <span style="color: #800000;">&quot;tralala&quot;</span></pre></div></div>

<p>Cette commande toute simple, permet de faire un snapshot massif sur plusieurs VM simultanément.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">get<span style="color: pink;">-</span>vm <span style="color: pink;">-</span>location <span style="color: #800000;">&quot;cluster&quot;</span> <span style="color: pink;">|</span>select name<span style="color: pink;">,</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>N<span style="color: pink;">=</span><span style="color: #800000;">&quot;store&quot;</span>;E<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#40;</span>get<span style="color: pink;">-</span>datastore <span style="color: pink;">-</span>vm <span style="color: #000080;">$_</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span>where <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.store <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;datastore1|datastore2&quot;</span><span style="color: #000000;">&#125;</span></pre></div></div>

<p>Cette commande permet de lister les vm d&#8217;un cluster ayant un vmdk,vmx ou iso sur le datastore1 ou datastore2.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">get<span style="color: pink;">-</span>template <span style="color: #800000;">&quot;template&quot;</span><span style="color: pink;">|</span>Get<span style="color: pink;">-</span>HardDisk</pre></div></div>

<p>Cette commande simplissime permet tout simplement des lister les vmdk d&#8217;un template sans le changer en vm.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;">Get<span style="color: pink;">-</span>VMHost <span style="color: pink;">-</span>location <span style="color: #800000;">&quot;cluster&quot;</span> <span style="color: pink;">|</span>Get<span style="color: pink;">-</span>View <span style="color: pink;">|</span> <span style="color: pink;">%</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.ReconfigureHostForDAS_Task<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span></pre></div></div>

<p>Cette commande exécute la tache &#8220;Reconfigure for VMware HA&#8221; sur les membres du cluster.</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>VMHost <span style="color: pink;">|</span>Get<span style="color: pink;">-</span>View <span style="color: pink;">|</span>select name<span style="color: pink;">,</span> <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>N<span style="color: pink;">=</span><span style="color: #800000;">&quot;socket&quot;</span>;E<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.Hardware.CpuInfo.NumCpuPackages <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Measure-Object</span> socket <span style="color: #008080; font-style: italic;">-Sum</span><span style="color: #000000;">&#41;</span>.sum</pre></div></div>

<p>Cette commande vous permet de remonter le nombre de socket contenu dans votre VC, pratique pour les licences&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hypervisor.fr/?feed=rss2&amp;p=1655</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
