If you'd like to contribute to the script library (highly appreciated), please ensure that you're script follows similarly to the example below and are easy to follow. Any script that doesn't follow these guidelines will not be approved.
Rules of Posting
Do not include sensitive data in your script (e.g., API Key and Hudu URL)
Verify that the script works
In your post, include:
Title (name of post)
Purpose/description/sample use case (what does it do)
Key features (highlights)
Scripting language used
Screenshots of your script in action (if possible)
In your script, include:
Purpose/description
Author (optional)
Date (optional)
Prerequisites (e.g. installing Hudu API module and key retrieval)
Notes, commenting out what each part of your script is doing
Storing API Keys
We recommend storing your API keys in a secure storage vault like Azure Key Vault. To do so, you can add the code below to the start of your script and customize. For additional information, visit How to setup an Azure Key Vault for Hudu's API.
# -------------------------------------------------------------------------
# User Environment
# -------------------------------------------------------------------------
# Before starting, you'll need to set 3 variables, just below their explanations.
# 1. Set your Azure Key Vault name
# 2. Set the name of your secret (which holds Hudu API key)
# 3. Set the URL of your Hudu instance-
$AzVault_Name = "ENTER YOUR KEY VAULT NAME HERE"
$AzVault_HuduSecretName = "ENTER YOUR KEY VAULT SECRET NAME HERE"
$HuduBaseURL = "HTTPS://YOUR.HUDU.DOMAIN"
# -------------------------------------------------------------------------
# Init Modules and Sign-In
# -------------------------------------------------------------------------
foreach ($module in @('Az.KeyVault', 'HuduAPI')) {
if (Get-Module -ListAvailable -Name $module) {
Write-Host "Importing module, $module...";
Import-Module $module
} else {
Write-Host "Installing and importing module $module...";
Install-Module $module -Force -AllowClobber;
Import-Module $module
}
}
if (-not (Get-AzContext)) {
Connect-AzAccount };
New-HuduAPIKey "$(Get-AzKeyVaultSecret -VaultName "$AzVault_Name" -Name "$AzVault_HuduSecretName" -AsPlainText)"
New-HuduBaseUrl $HuduBaseURL
# Unset/Remove Hudu API Key
Remove-HuduAPIKey