-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebapps.psm1
More file actions
38 lines (27 loc) · 1.66 KB
/
webapps.psm1
File metadata and controls
38 lines (27 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function Get-AzsWebAppStatus {
[CmdletBinding(DefaultParameterSetName = 'GetAzsWebbAppStatus')]
Param(
[Parameter(Mandatory = $true)]
[ValidateNotNullorEmpty()]
[String] $location,
[Parameter(Mandatory = $true)]
[ValidateNotNullorEmpty()]
[String] $armendpoint,
[Parameter(Mandatory = $true)]
[ValidateNotNullorEmpty()]
[System.Management.Automation.PSCredential] $Armcredentials
)
$azureEnvironment=Add-AzureRmEnvironment -Name "AzureStackWebAppAdmin" -ARMEndpoint $armendpoint
$azureAccount = Add-AzureRmAccount -Environment "AzureStackWebAppAdmin" -Credential $Armcredentials
$AzureSubscription = Get-AzureRmSubscription |where-object {$_.Name -eq "Default Provider Subscription"}
$AzureSubscriptionID = $AzureSubscription.ID
# Retrieve the access token
$tokens = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.TokenCache.ReadItems()
$token = $tokens |Where Resource -EQ $azureEnvironment.ActiveDirectoryServiceEndpointResourceId |Where DisplayableId -EQ $azureAccount.Context.Account.Id |Sort ExpiresOn |Select -Last 1
$uri1 = "$($azureEnvironment.ResourceManagerUrl.ToString().TrimEnd('/'))/subscriptions/$($AzureSubscriptionID.ToString())/resourceGroups/AppService.$location/providers/Microsoft.Web.Admin/locations/$location/servers?api-version=2016-08-01"
$Headers = @{ 'authorization' = "Bearer $($Token.AccessToken)"}
$Servers = (Invoke-RestMethod -Method GET -Uri $uri1 -Headers $Headers)
$Serversprop=$servers.properties
$Serversprop
}
Export-ModuleMember -Function Get-AzsWebAppStatus