Quantcast
Channel: VMware Communities : All Content - VMware PowerCLI
Viewing all articles
Browse latest Browse all 16717

Invoke-VMScript

$
0
0

hi,

I am trying to run the invoke command to scan for new disk and add them to the vm,

but somehow this is not working, i know the script text works. please help

 

$createDisk=@"

$disks = Get-Disk |Where-Object {$_.PartitionStyle -eq 'RAW'}                                                                                                                                                                                                             

foreach ($disk in $disks){Get-Disk |Where PartitionStyle -eq 'RAW' |Initialize-Disk -PartitionStyle MBR -PassThru|New-Partition -AssignDriveLetter -UseMaximumSize |Format-Volume -FileSystem NTFS -NewFileSystemLabel "Data $i"  -Confirm:$false}

"@

Invoke-VMScript -VM $vmname  -ScriptText $createDisk -GuestUser $Lcredentials.UserName  -GuestPassword $Lcredentials.Password -ScriptType Powershell  -Verbose

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

|  + & { 41 42 43 = Get-Disk |Where-Object {.PartitionStyle -eq 'RAW'}

|  +        ~~

|  Unexpected token '42' in expression or statement.

|  At line:1 char:11

|  + & { 41 42 43 = Get-Disk |Where-Object {.PartitionStyle -eq 'RAW'}

|  +           ~~

|  Unexpected token '43' in expression or statement.

|  At line:2 char:11

|  +  foreach (3 in 41 42 43){Get-Disk |Where PartitionStyle -eq 'RAW' |In ...

|  +           ~

|  Missing variable name after foreach.

|  At line:2 char:13

|  +  foreach (3 in 41 42 43){Get-Disk |Where PartitionStyle -eq 'RAW' |In ...

|  +             ~~

|  Unexpected token 'in' in expression or statement.

|  At line:1 char:3

|  + & { 41 42 43 = Get-Disk |Where-Object {.PartitionStyle -eq 'RAW'}

|  +   ~

|  Missing closing '}' in statement block or type definition.

|  At line:2 char:24

|  +  foreach (3 in 41 42 43){Get-Disk |Where PartitionStyle -eq 'RAW' |In ...

|  +                        ~

|  Unexpected token ')' in expression or statement.

|  At line:2 char:240

|  + ... olume -FileSystem NTFS -NewFileSystemLabel "Data 3"  -Confirm:False}}

|  +                                                                         ~

|  Unexpected token '}' in expression or statement.

|  At line:1 char:11

|  + & { 41 42 43 = Get-Disk |Where-Object {.PartitionStyle -eq 'RAW'}

|  +           ~~

|  The assignment expression is not valid. The input to an assignment operator must be an object that is able to accept

|  assignments, such as a variable or a property.

|      + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException

|      + FullyQualifiedErrorId : UnexpectedToken

|  


Viewing all articles
Browse latest Browse all 16717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>