Reputation: 1511
I am having questions around the "Stop-AzureRmVm" PowerShell cmdlet. Does the cmdlet power crash the virtual machines? I have few SharePoint and SQL servers used in our non-production environment. I have powershell scripts that do a scheduled stop and start of these virtual machines.
I am worried if the "Stop-AzureRmVm" PowerShell cmdlet power crashes the virtual machines, as I need the servers to gracefully shutdown.
OR do we have any PowerShell cmdlet that gracefully shuts down the Azure virtual machine?
Upvotes: 2
Views: 3473
Reputation: 11
Sorry to revive an old question, but Ken W's accepted answer here is not accurate. The -Force parameter only prevents a Yes/No prompt when running the cmdlet (this is useful for when running in an automated script which cannot accept user input). Either way, running Stop-AzureRmVm will always attempt a graceful shutdown.
The newer 'Az' version of this cmdlet (Stop-AzVM) does have a -SkipShutdown option which will skip any attempt at a graceful shutdown, and will immediately deallocate the VM. More details can be found in the following link:
https://learn.microsoft.com/en-us/powershell/module/az.compute/stop-azvm
Upvotes: 0
Reputation: 42043
Dont worry, the command Stop-AzureRmVm
will gracefully shut down the VM.
If you catch the request of the Stop-AzureRmVm
and the Stop
option of the VM in the portal, you will find essentially they all call the Virtual Machines - Deallocate
REST API, it means if you use the powershell command, it is no difference with that in the portal.
Upvotes: 2
Reputation: 3804
As long as you are not sending the -force
parameter, Azure will attempt to gracefully shutdown the guest OS before stopping. If that doesn't work, the -force
parameter is akin to "pulling the plug".
Upvotes: 3