<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Check the tag on VM according to the tag in the file in VMware PowerCLI Discussions</title>
    <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-the-tag-on-VM-according-to-the-tag-in-the-file/m-p/2921023#M107567</link>
    <description>&lt;P&gt;&lt;STRONG&gt;LucD &lt;/STRONG&gt;It works, thank you very much for help!&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jul 2022 09:50:36 GMT</pubDate>
    <dc:creator>Toniccc</dc:creator>
    <dc:date>2022-07-28T09:50:36Z</dc:date>
    <item>
      <title>Check the tag on VM according to the tag in the file</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-the-tag-on-VM-according-to-the-tag-in-the-file/m-p/2921005#M107564</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a file with correct tags of the environment (prod,test,dev). I need to read the VM name and tag&amp;nbsp; from the file and if itsn't equal to the tag in vSphere change it. I wrote a script but I couldn't understand how to compare the data in file (string) with tag on VM which is not a string. Could you help me to fix my script?&lt;/P&gt;&lt;P&gt;$vmlist = Import-CSV 'C:\tools\change_tag_to_vm.csv' -Delimiter ";"&lt;/P&gt;&lt;P&gt;foreach ($item in $vmlist)&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp;$vmname = $item.vmname #VMname&lt;BR /&gt;&amp;nbsp; &amp;nbsp;$env = $item.env #Environment vm_landscape tag&lt;BR /&gt;&amp;nbsp; &amp;nbsp;$oldtag=Get-TagAssignment -Category VM_Landscape -Entity $vmname&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if ($oldtag -ne $env)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Remove-TagAssignment -tag $oldtag confirm:$false&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;New-TagAssignment -Tag $env -Entity $vmname&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 07:56:53 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-the-tag-on-VM-according-to-the-tag-in-the-file/m-p/2921005#M107564</guid>
      <dc:creator>Toniccc</dc:creator>
      <dc:date>2022-07-28T07:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Check the tag on VM according to the tag in the file</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-the-tag-on-VM-according-to-the-tag-in-the-file/m-p/2921013#M107565</link>
      <description>&lt;P&gt;You could test like this&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;if ($oldtag.Tag.Name -ne $env)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 28 Jul 2022 08:42:34 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-the-tag-on-VM-according-to-the-tag-in-the-file/m-p/2921013#M107565</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2022-07-28T08:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: Check the tag on VM according to the tag in the file</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-the-tag-on-VM-according-to-the-tag-in-the-file/m-p/2921023#M107567</link>
      <description>&lt;P&gt;&lt;STRONG&gt;LucD &lt;/STRONG&gt;It works, thank you very much for help!&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jul 2022 09:50:36 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Check-the-tag-on-VM-according-to-the-tag-in-the-file/m-p/2921023#M107567</guid>
      <dc:creator>Toniccc</dc:creator>
      <dc:date>2022-07-28T09:50:36Z</dc:date>
    </item>
  </channel>
</rss>

