Download: Anzeigen von VMs die länger als 7 Tage laufen.zip

 

Select-AzSubscription „xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx“
$numberofdays = (get-date).AddDays(-7)
$vms = get-azvm -status
foreach ($vm in $vms)
{
if ($vm.powerstate -ceq „VM running“)
{
$foundvm = get-azvm -resourcegroup $vm.ResourceGroupName -name $vm.Name -status
if ($foundvm.Statuses.Time -le $numberofdays)
{
write-output „$($foundvm.name)“
}