VMware Cloud Community
online11
Contributor
Contributor
Jump to solution

Add New Harddisk from a txt file

Hi there,

I have list of VMs under "cluster1" and there are specific VMs on a txt file and want to add secondary 10GB thin disks to those VMs.

New disks will be created in datastore: DATASTORE1

ClusterName: Cluster1

Can you help me on this. Thanks.

Get-Content C:\VMs.txt | %{

  $Cluster = Get-VM -Name $_ | Get-Cluster | Select -ExpandProperty Name

  $dsname = "DATASTORE1"

    }

  New-HardDisk -VM $_ -CapacityGB 10 -DiskType Flat -Datastore $dsname -StorageFormat Thin

}

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-Content C:\VMs.txt | %{

    Get-VM -Name $_ |

    New-HardDisk -CapacityGB 10 -DiskType Flat -Datastore "DATASTORE1" -StorageFormat Thin 

}

  

If the TXT file contains all the VM names, there is no need to get the cluster.


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-Content C:\VMs.txt | %{

    Get-VM -Name $_ |

    New-HardDisk -CapacityGB 10 -DiskType Flat -Datastore "DATASTORE1" -StorageFormat Thin 

}

  

If the TXT file contains all the VM names, there is no need to get the cluster.


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

0 Kudos
online11
Contributor
Contributor
Jump to solution

Thanks master 🙂

0 Kudos