Hi Everyone,
Recently, i tested the script from LucD, but not sure if it will work on schedule time or not tomorrow because of recent error
Why every time its throwing an error for Name parameter.
$vmNames = Get-Content -Path C:\Temp\vmnames.txt
$vms = Get-VM -Name $vmNames |
where{$_.PowerState -eq 'PoweredOn'}
Shutdown-VMGuest -VM $vms -Confirm:$false
while((Get-VM -Name $vmNames).PowerState -contains 'PoweredOn'){
sleep 5
}
$vms | Select Name | Export-Csv C:\Temp\vm-powered-off.csv -NoTypeInformation -UseCulture
**************************************************************************
For Power on
$vmNames = Import-Csv -Path C:\Temp\vm-powered-off.csv -UseCulture
Get-VM -Name $vmNames.Name |
Start-VM -Confirm:$false
Isn't that the same problem we just had, where there seems to be a blank line in the .txt file.
Try replacing the line with
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Isn't that the same problem we just had, where there seems to be a blank line in the .txt file.
Try replacing the line with
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Please try the solution LucD gave you for your other question (Re: Can we pull VMware tools version and VM's HW version for specific lists of VMs ?), i.e. skiping any blank lines.
André
Thank you Will replace as you suggestion. I was worried because first, we are doing non-prod followed by Prod.
Sorry its failing to poweron
$vmNames = Import-Csv -Path C:\Temp\vm-powered-off.csv -UseCulture
Get-VM -Name $vmNames.Name |
Start-VM -Confirm:$false
#############################################################################
even the 2nd also not working failing with same error
$vmNames = Get-Content -Path C:\Temp\vmliste.txt | where{$_}
Get-VM -Name $vmNames.Name |
Start-VM -Confirm:$false
LucD,
Finally below script saved me for bulk VMs power-on requirement, otherwise, it would have been manual tasks for me
foreach($vmlist in (Get-Content -Path C:\TEMP\vmliste.txt)){
$vm = Get-VM -Name $vmlist
Start-VM -VM $vm -Confirm:$false
}
I find it hard to believe that this issue is not caused by a blank line in your .txt file (which you confirmed in a previous thread).
Also strange that one time you seem to use a .txt file, and the other you seem to use a .csv file..
The script that fixes the issue, according to you, has no provision for blank lines in the .txt file.
Something else must have changed
Very hard to pinpoint an issue when you don't share all the information
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
What I also find very strange, you retract my Correct Answer, which is your good right.
But you keep the Like you gave to another answer, that just repeated my answer.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
My apologies, it was my mistake since there were multiple console were open and it was retracted by mistake. Sorry once again.
thanks
vmk
No problem, I guessed as much :smileygrin:
Is everything working as planned now?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you LucD, Everything worked on the plan. Since it was a bulk upgrade and I was worried about the downtime Window.