VMware Cloud Community
jamesreinke2
Enthusiast
Enthusiast
Jump to solution

WARNING: Parameter 'VM' is obsolete. This parameter no longer accepts multiple values.

When running the script below

#import list of servers from text file

$Servers = Get-Content -Path “c:\VMlist.txt”

# Take snapshot of each vm

foreach($Server in $Servers){

Get-VM -Name $Server | New-Snapshot -Name "Take 2" -Description "blah blah blah" # -Quiesce -Memory

}

I recieve this error "WARNING: Parameter 'VM' is obsolete. This parameter no longer accepts multiple values."

Is there anyway around this or is thee a better way?

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The message might be a bit misleading.

The VM parameter is not obsolete, only the possibility to pass multiple values (an array) on the parameter.


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

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

The message might be a bit misleading.

The VM parameter is not obsolete, only the possibility to pass multiple values (an array) on the parameter.


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

Reply
0 Kudos
Chris_95
Contributor
Contributor
Jump to solution

Hello,

What is the solution to pass multiple VM in txt file ?

Thanks for return.

 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Not sure what you mean?
On the Get-VM Name parameter you can still pass an array of names.
On the New-Snapshot VM parameter you can only pass 1 VM.
But if you are using both in a pipeline, the New-Snapshot will only get 1 VM object per call.

The following for example should still work.

Get-VM -Name (Get-Content -Path .\vmnames.txt) |
New-Snapshot -Name Test



 


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

Reply
0 Kudos
Chris_95
Contributor
Contributor
Jump to solution

Hello again LuD !

Thanks for your reply.

In fact : many days to try to understand why my very simple script didn't work :

$vmlist = Get-Content -Path "C:\Powercli\Powercli_VMWARE\Scripts\Checked\vmnames.txt"
foreach($vmname in $vmlist){
Get-VM -Name $vmname }

The error message : (see many many times in forum...)

Chris_95_0-1658752631376.png

The real reason of this trouble IS NOT THE SCRIPT but the file format about... TXT FILE !

YES be careful that the response file is well written in UTF-8 FORMAT !

 

 

 

Reply
0 Kudos