[Azure] Use Azure PowerShell script to view cloud service IP address bindings for all subscriptions under your account

Source: Internet
Author: User
Tags foreach

This script can view the fixed situation of the public IP of the cloud service in Classic mode, so that the administrator could view and fix the VIP of the cloud service that need to be fixed but not fixed in time.


The code is as follows:

$cred = get-credential-message "Use your Azure account to login"; [void]

(Add-azureaccount-environment azurechinacloud-credential $cred);

$subscriptions = get-azuresubscription; foreach ($subscription in $subscriptions) {$subscriptionName = $subscription.
    Subscriptionname; [void] (Select-azuresubscription-subscriptionid $subscription.
    SubscriptionId);

    Write-host "==============" $subscriptionName "=============="; $serviceNames = Get-azureservice-erroraction Ignore |
    Select ServiceName; $reservedServices = Get-azurereservedip-erroraction Ignore | Where-object {$_.
    Servicename-ne $null};
        foreach ($serviceNameObj in $serviceNames) {$flag = $true; foreach ($reservedServiceObj in $reservedServices) {if ($serviceNameObj. Servicename-eq $reservedServic Eobj.servicename) {write-host "[Reserved] Cloud Service Name:" $SERVICENAMEOBJ. ServiceName "R eserved IP Name: "$RESERVEDSERVICEOBJ. Reservedipname-Foregroundcolor Green;
                $flag = $false;
            Break }} if ($flag) {write-host "[unreserved] Cloud Service Name:" $SERVICENAMEOBJ. Servicen
        Ame-foregroundcolor Red; }
    }
}


Examples of output results:




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.