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
}
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
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
Thanks master 🙂