This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-PCAppUserAuthenticationBearer { | |
<# | |
.SYNOPSIS | |
Function to retrieve App+User bearer token from Microsoft CSP API | |
.DESCRIPTION | |
This function connects to Azure AD to generate an oAuth token. | |
Aquired token is then used against the partner center REST API to generate a App+User jwt token. https://api.partnercenter.microsoft.com/generatetoken | |
You can read more about the authentication method here: https://msdn.microsoft.com/en-us/library/partnercenter/mt634709.aspx | |
.PARAMETER ClientID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Function to connect to the Microsoft login OAuth endpoint and return an OAuth token. | |
.DESCRIPTION | |
Generate Azure AD oauth token. | |
You can specify the resource you want in the paramenter. Default is management.core.windows.net | |
Parts of this function is created from these examples: https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-rest-api-walkthrough | |
.PARAMETER ClientID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#get the health of the whole resource group | |
# Add each health status to a hashtable before output a complete table with all resource groups and their resource health | |
$resourceGroupHealth = @{} | |
foreach ($ResourceGroup in $ResourceGroups) { | |
#Set resource group name and use it in our url | |
$health = Invoke-RestMethod -Uri "https://management.azure.com/subscriptions/$subscriptionID/resourceGroups/$ResourceGroup/Providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2015-01-01" -Method GET -Headers $authHeader | |
$currentHealth = @{} | |
$currentHealth = @{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function send-altoxCommand { | |
param ( | |
[Parameter(Mandatory = $true)] | |
$command, | |
[Parameter(Mandatory = $true)] | |
$pass, | |
[Parameter(Mandatory = $true)] | |
$email, | |
[Parameter(Mandatory = $true)] | |
$id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Azure functions powershell http trigger | |
#Get input | |
$input = Get-Content $req -Raw | ConvertFrom-Json | |
[int]$tempLow = $input.tempLow | |
[int]$heatingMinutes = $input.heatingMinutes | |
function send-altoxCommand { | |
param ( | |
[Parameter(Mandatory = $true)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Request the certificate throuh template called "WebServer" | |
Get-Certificate -Template "WebServer" -DnsName "computername.fqdn" -CertStoreLocation cert:\LocalMachine\My -SubjectName "CN=computerName.fqdn, C=CountryCode, L=MyCity, O=Organization OU=Department, S=State" | |
# After approval. Use request to download and install cert | |
$cert = (get-childItem -path cert:\LocalMachine\Request) | |
get-certificate -Request cert:\LocalMachine\Request\$cert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$alertRules = Invoke-RestMethod -Method GET "https://management.azure.com/subscriptions/$SubscriptionId/resourcegroups/$ResourceGroupName/providers/microsoft.insights/alertrules?api-version=2016-03-01" -Headers $authHeader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$result = Get-AADAppoAuthToken -ClientID $AzureApplicationID -ClientSecret $ClientSecret -TenantId $TenantId | |
$AuthKey = "Bearer " + ($result.access_token) | |
$authHeader = @{ | |
'Content-Type' = 'application/json' | |
'Accept' = 'application/json' | |
'Authorization' = $AuthKey | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Alert = $alertrules.id | |
(Invoke-RestMethod -Method GET "https://management.azure.com/$alert/incidents?api-version=$apiversion" -Headers $authHeader).value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
# Your azure ad application ID | |
[Parameter(Mandatory)] | |
[String] | |
$AzureApplicationID, | |
# Azure AD application secret | |
[Parameter(Mandatory)] | |
[String] | |
$ClientSecret, |
OlderNewer