VMware Cloud Community
jingleharish
Contributor
Contributor

Testing monitors

Hi-

We are in process of tesing our new monitoring system; Hence we are suppose to add & remove a dummy vmdk to around 300VM's, To see if this alert is picked by the monitoring unit. Please let me know of a script that will help me doing this task of adding and removing vmdk's.

Thanks in advance.

Tags (1)
0 Kudos
1 Reply
LucD
Leadership
Leadership

Try somehting like this

Get-VM | New-HardDisk -DiskType "flat" -StorageFormat "Thin" -CapacityKb 1024 -Datastore "MyDS" -Confirm:$false -DiskPath "[MyDS] Test/" + $_.Name + "_test.vmdk"

Note that I added an explicit .vmdk name. That will make it easier to remove the .vmdk later on.

The remove can be done with something like this

Get-VM | Get-HardDisk | Where {$_.Filename -like "[MyDS] Test/*" | Remove-HardDisk -Confirm:$false

You will have to create the folder "[MyDS] Test" before of course !


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

0 Kudos