Script to get all VMs that automatically start with a host and remove the automatic startup functionality. Im not even sure how to start this. I imagine to find all VMs that start with a host, it would be something like this:
Foreach($VM in Get-VM) | Select-Object Name, AutomaticStartAction
But the above doesn't populate the AutomaticStartAction column. And I don’t know the command to remove the AutomaticStart Action
Any help would be appreciated
You can do
Get-VM | Get-VMStartPolicy | select VM,StartAction
For changing the setting, have a look at Powercli to set "manual start" of vm instead of 'automatic startup'?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can do
Get-VM | Get-VMStartPolicy | select VM,StartAction
For changing the setting, have a look at Powercli to set "manual start" of vm instead of 'automatic startup'?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you!! And i assume to change the policy to turn it off the command would be:
$vmstartpolicy = Get-VM | Get-VMStartPolicy
Set-VMStartPolicy -StartPolicy $vmstartpolicy -StartAction None
Is that correct?
Correct
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This doesn't work for me
Get-VM | Get-VMStartPolicy | select VM,StartAction
this cmd doesn´t work for me. Could you help me extension of cmd with get-VM StartPolicy.
My case is that i need report of whole VM´s from my vcenter. Bcz when i try use cmd Get-VMStartPolicy - VM myvm function well, but I need for each other WM´s.
Thanks for answer.
What doesn't work?
Any error messages?
Which PowerShell and PowerCLI version?
Which vSphere version?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
1.] error messages - object reference not set to an instance of an object
2.] PowerCLI version - 6.5.0.234
3.] vsphere version - 6.7.0
target : Retrieves the start policy of the virtual machine´s.
Start by updating your PowerCLI version
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I need export the VMStartpolicy with VMName, Host, Start action, start delay, start order
use this script:
Get-vm -Name "xxxyyy" | Get-VMStartPolicy | select VM,StartAction,StartDelay,StartOrder,VMHost | Export-Csv "C:test.csv"
on the csv i see all infromation without vmhost
Use a calculated property
Get-vm -Name "xxxyyy" | Get-VMStartPolicy |
select VM,StartAction,StartDelay,StartOrder,@{N='VMHost';E={$_.VM.VMhost.Name}} |
Export-Csv "C:test.csv"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
with this script i see vm on "Manual startup"
Yes, is there a question in there?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
sorry I forgot "?"
That is not the point, what would you expect it to show?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
i want see the vmname-startaction-startdelay-startorde-vmost
i run the script and generate csv file, into the file i see all information but wher the script running i receve a multiple error "
Get-VMStartPolicy: 09/27/2021 14:47:08 Get-VMStartPolicy Reference to an object not set to an object instance.
In row: 1 car: 11
+ Get-vm | Get-VMStartPolicy | select VM, StartAction, StartDelay, StartO ...
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo: NotSpecified: (:) [Get-VMStartPolicy], VimException
+ FullyQualifiedErrorId: Core_BaseCmdlet_UnknownError, VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetVMStartPolicy
Then there might be something wrong in your environment.
Orphaned VMs, ghost entries ....
Is a simple Get-VM producing the same errors?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
i run the get-vm | export-csv "c:test.csv" and no recived any error
And what about
Get-vm | Get-VMStartPolicy
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
in this case i recived error