Hi all,
I have the following script I wrote and for some reason when I run it, I get a "supply values for the following parameter" although all the parameters values were included in a CSV file I created for input.
The script is used for mapping virtual disks to my VMs.
This is my script:
Import-Csv -Path Luns.csv | ForEach-Object `
{
$vm = Get-VM $_.VM
$LunType = $_.LunType
if (LunType eq "RDMP")
{
$Lun = $_.Lun
$deviceName = ($vm | Get-VMHost | Get-ScsiLun | Where-Object {$_.RunTimeName.Split(":")[3].TrimStart("L") -eq $Lun}).ConsoleDeviceName
New-HardDisk -VM $vm -DiskType RawPhysical -DeviceName $deviceName
}
elseif (LunType eq "VMFS")
{
$LunSize = $_.LunSize
$Datastore = $_.DataStore
New-HardDisk -VM $vm -Datastore $Datastore -CapacityKB $LunSize*1024*1024
}
Invoke-VMScript -vm $vm -guestuser administrator -guestpassword kashya -scripttype bat -scripttext "diskpart /s c:\part.txt"
Invoke-VMScript -vm $vm -guestuser administrator -guestpassword kashya -scripttype bat -scripttext "echo y | format e: /q /fs:ntfs /v:"
}
And this is my CSV:
VM | Lun | LunType | LunSize | DataStore |
Clus1VM3 | 1 | RDMP | | |
Clus1VM3 | 2 | RDMP | | |
Clus1VM5 | 3 | RDMP | | |
Clus1VM5 | VMFS | 5 | DS3 |
Clus1VM6 | 5 | RDMP | | |
Clus1VM7 | VMFS | 5 | DS3 |
Thanks for the help,
Nir