title: How to pull last boot time (up time) from an Azure VM with Powershell
body: <p>I'm having difficulties finding a good way to indefinitely define how long a VM has been running in azure without writing code that executes on the host of each VM. I'm trying to find a way to programmatically pull the up time or last boot time for several hundred VMs at once. Most of them should have app insights enabled and I've found this &quot;Last boot&quot; feature which is close enough because I can work backwards with that to determine the uptime. I was wondering if there's a way to pull this insights metric with PowerShell, or if there's a better way to pull uptime per vm so ultimately I can iterate through my list of VMs and record all of their uptimes.</p>
  <p><a href="https://i.stack.imgur.com/kKjEY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kKjEY.png" alt="App insights Last Boot" /></a></p>