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?
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
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
Hello,
What is the solution to pass multiple VM in txt file ?
Thanks for return.
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
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...)
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 !