VMware Cloud Community
ictadminrbassi
Enthusiast
Enthusiast

how to Interrogate VMs in sub folders locations

Hi Fellow VM Admins

I have got a question regarding a PowerShell script which was developed by one of our previous VM admins who was a bit of script guru who managed to create a script which we use as part of disaster recovery process.

Unfortunately my knowledge with PowerShell scripts is limited and I could do with some help.

In summary  we use this script as part of our DR recovery process to clone our volumes from our NetApp array using the NetApp flexclone method to bring our VMs online within minutes however the performance of that array is poor so we want to utilize another array which has higher performing disks. We use this PowerShell script to effectively interrogate a particular VM folder and it will literally process any VMs located on a particular storage which starts with the name 'snap' and if it identifies this, it will the move to another storage array in a sequential order.

As part of one of the variables defined we use $VM_LOCATION so the script knows which folder to look in to interrogate but ideally I need to amend this slightly so that it can interrogate sub folders within that main folder.

I attach the script in txt format.

Is this possible? Is anyone able to help me?

I have tried to look for a variable which would meet this need but I cant seem to find one.

Any help on this would be most appreciated.


Many Thanks

Reply
0 Kudos
9 Replies
LucD
Leadership
Leadership

If I understand correctly, you want tpspecify a blue folder in $VM_LOCATION, but you want the selection of VMs (which goes into $FoundVMs), to also look in all subfolders of the folder specified in $VM_LOCATION.

For example:

- you have the following blue folder hierachy

     Folder1

          Folder2

               Folder3

          Folder3

- when you specify 'Folder1' in $VM_LOCATION, you want the script to also look for VMs in the blue folders Folder2, Folder3 and Folder4.

Is my interpretation correct?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ictadminrbassi
Enthusiast
Enthusiast

Hi LucD

That's correct I want it to look through the whole hierarchy.

Reply
0 Kudos
LucD
Leadership
Leadership

Attached a new version which should be handling subfolders.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ictadminrbassi
Enthusiast
Enthusiast

Thanks for this.

I tried to run it with the correct variables but it doesn't seem to process for some reason.

It doesn't however provide an error so assume the code is ok but don't understand why its not processing.  I attach an output when I run using Powershell ISE which has the VMware snapin.

Thanks

Reply
0 Kudos
LucD
Leadership
Leadership

There should be output in this log.txt file.

Or is that empty as well?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ictadminrbassi
Enthusiast
Enthusiast

Its not helpful unfortunately. Its just purely an output of what is running.

** 2017-10-06 14:58:24  **
Scripted SVMotion started
** 2017-10-06 14:58:36  **

Name                           Port  User                         
----                           ----  ----                         
vCentreServer                  443   DOMAIN\myusername     

** 2017-10-06 14:58:37  **

Reply
0 Kudos
LucD
Leadership
Leadership

I was expecting to see the content of the $FoundVMs variable.

What you posted is all that is in the log?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
ictadminrbassi
Enthusiast
Enthusiast

Yes just that unfortunately.

Reply
0 Kudos
LucD
Leadership
Leadership

Ok, added extra logging after my code addition.
Can you check if this produces more info in the log?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos