<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>PowerCLI on MichelleWayZ | Michelle Goossens | Blog</title><link>https://blog.michellewayz.com/categories/powercli/</link><description>Recent content in PowerCLI on MichelleWayZ | Michelle Goossens | Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>Copyright © 2019-2026, Michelle Goossens.</copyright><lastBuildDate>Wed, 11 Dec 2019 07:25:00 +0000</lastBuildDate><atom:link href="https://blog.michellewayz.com/categories/powercli/index.xml" rel="self" type="application/rss+xml"/><item><title>More PowerCLI scripts to make life easier!</title><link>https://blog.michellewayz.com/more-powercli-scripts-to-make-life-easier/</link><pubDate>Wed, 11 Dec 2019 07:25:00 +0000</pubDate><guid>https://blog.michellewayz.com/more-powercli-scripts-to-make-life-easier/</guid><description>
&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;Inspired by my last blog post, here are more PowerCLI scripts to make life easier.&lt;/p&gt;
&lt;p&gt;Script one; get VMs on a specific host with a specific Port Group&lt;/p&gt;
&lt;pre class="wp-block-code"&gt;&lt;code lang="powershell" class="language-powershell"&gt;$viserver = "vCenter IP/FQDN here"
$t_host = "ESXi FQDN/IP here as used in vCenter"
$portgroup = "port group name here"
Connect-VIServer $viserver
Get-Cluster -VMHost $t_host | Get-VMHost | Get-VM | Get-NetworkAdapter | Where-Object{$_.NetworkName -like $portgroup}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Script two; get VMs on a specific host with a specific Port Group and move them over to a new Port Group&lt;/p&gt;</description></item><item><title>Easy PowerCLI script to help migrate VMs from one network to the other.</title><link>https://blog.michellewayz.com/easy-powercli-script-to-help-migrate-vms-from-one-network-to-the-other/</link><pubDate>Sat, 07 Dec 2019 06:00:00 +0000</pubDate><guid>https://blog.michellewayz.com/easy-powercli-script-to-help-migrate-vms-from-one-network-to-the-other/</guid><description>
&lt;p&gt;Hi everyone,&lt;/p&gt;
&lt;p&gt;In this post I am sharing a PowerCLI script that I made in order to easily migrate VMs from one network to the other.&lt;/p&gt;
&lt;p&gt;There are two versions of this script, one version has a hard-coded ESXi/vCenter instance, and the other one asks for the vCenter on each run.&lt;/p&gt;
&lt;p&gt;Version 1 (hard coded ESXi/vCenter):&lt;/p&gt;
&lt;pre class="wp-block-code"&gt;&lt;code lang="powershell" class="language-powershell line-numbers"&gt;Do {
$vspherehost = "ADD-ME"
$src = Read-Host -Prompt "Input source network"
$dst = Read-Host -Prompt "Input destination network"
Connect-VIServer $vspherehost
Get-VM | Get-NetworkAdapter | where{$_.NetworkName -like $src} | Set-NetworkAdapter -NetworkName $dst
} while($true)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Version 2 (Asks for ESXi/vCenter on reach run):&lt;/p&gt;</description></item></channel></rss>