Most of the time, when we want to check consumption to keep an eye on our Azure VM costs, we use Azure Portal because it is easier to narrow down and get the number that you are looking for.
Sometimes, you may want to do a quick check on a given VM to identify the costs, and that is one of the requests that I received today. We have the Get-AzConsumptionUsageDetail cmdlet that helps exactly on that front. However, the output has a lot of information and lacks totals, which makes it harder when you need a simple answer like how much that VM cost last month or the cost so far this month.
I created a script that you provide the VM name, and it will give you the cost of the current cycle and the previous month.
You can use the following link to get access to the Azure VM costs script.