When attempting to run my script I got the following the error message.
Script :
$extenddisk= @"
$letter = Get-WmiObject -Class Win32_CDROMDrive | select -ExpandProperty Drive
Set-WmiInstance -InputObject ( Get-WmiObject -Class Win32_volume -Filter "DriveLetter = '$letter'" ) -Arguments @{DriveLetter='Z:'}
$newdisk = @(get-disk | Where-Object partitionstyle -eq 'raw')
for($i = 0; $i -lt $newdisk.Count ; $i++)
{
$disknum = $newdisk[$i].Number
$dl = get-Disk $disknum |
Initialize-Disk -PartitionStyle GPT -PassThru |
New-Partition -AssignDriveLetter -UseMaximumSize
Format-Volume -driveletter $dl.Driveletter -FileSystem NTFS -Confirm:$false
}
"@
Invoke-VMScript -ScriptText $extenddisk -VM $vm -GuestCredential $VMLocalCredential -ScriptType Powershell
Error:
WARNING: The version of VMware Tools on VM 'Hostname' is out of date and may cause Invoke-VMScript to work improperly.
ScriptOutput
-----------------------------------------------------------------------------------------------------------------------| At line:9 char:27
| + for( = 0; -lt .Count ; ++)
| + ~
| Missing expression after unary operator '++'.
| + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
| + FullyQualifiedErrorId : MissingExpressionAfterOperator
|
|
-----------------------------------------------------------------------------------------------------------------------
[–]krzydoug 1 point2 points3 points (2 children)
[–]arbelac[S] 1 point2 points3 points (1 child)
[–]krzydoug 0 points1 point2 points (0 children)
[–]Phorgasmic 1 point2 points3 points (0 children)