ranj Posted October 6, 2017 Posted October 6, 2017 Hi Admins Any VMware Power Cli experts out there? 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 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 ThanksvMotion_Script.txt
HPlum78 Posted October 6, 2017 Posted October 6, 2017 As far as I can see from https://www.vmware.com/support/developer/PowerCLI/PowerCLI41U1/html/Get-VM.html that should use recursion unless told not to do so? - not a vm man mind! 1
steve Posted October 9, 2017 Posted October 9, 2017 From what I can see, the script is using the variable $VM_LOCATION to filter a list of VMs found across your datastores ($DS_SOURCE_FILTER). $FoundVMs = Get-VM -Datastore $DS_SOURCE_FILTER |WHERE {($_.Folder -like $VM_LOCATION )} |SELECT Name, UsedSpaceGB So if you want to show VMs where $VM_LOCATION is just a part of the folder name, you could modify the part WHERE {($_.Folder -like $VM_LOCATION )} Something like WHERE {($_.Folder -like "*$VM_LOCATION*" )} should do it. You might have to play around with the quotes, it can be a bit tricky to get them right sometimes. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now