This file contains hidden or 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 | |
| Example code on how to post messages to a custom event grid topic | |
| .Notes | |
| part of a blog article on https://adatum.no | |
| #> | |
| $eventDate = get-date -Format s # get the date and time for the event. Has to be sortable for event grid to accept. Pass as a string | |
| $eagSASkey = "HCDs7UFipbBXZ0OPc+mM=2" # access key. |
This file contains hidden or 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 | |
| Creates an azure ad application and sets reader permissions on subscription | |
| .NOTES | |
| Script is provided as an example, it has no error handeling and is not production ready. App name and permissions is hard coded. | |
| #> | |
| param( | |
| [Parameter(Mandatory)] |
This file contains hidden or 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, |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 = @{ |