Skip to content

Instantly share code, notes, and snippets.

Avatar

Neeraj Kumar neerajks77

View GitHub Profile
View DSCIIS.ps1
Configuration WebServer
{
# declare the VMs as nodes for which the configuration will happen. This can be parameterized using parantheses as comma separated names
Node WebServerIIS
{
#ensure IIS is installed
WindowsFeature IIS
{
Name = 'web-server'
Ensure = 'Present'
@neerajks77
neerajks77 / ConfigureEdgeDevice.ps1
Last active May 1, 2021
This script deploys, installs, and configures the IoT Edge Runtime on the Windows device to configure the device as an edge device to which other leaf devices can connect
View ConfigureEdgeDevice.ps1
#Uninstall the IoT Edge module from the Windows device
. {Invoke-WebRequest -useb https://aka.ms/iotedge-win} | Invoke-Expression; Uninstall-IoTEdge -Force
#Deploy the IoT Edge Runtime module to the Windows device
. {Invoke-WebRequest -useb https://aka.ms/iotedge-win} | Invoke-Expression; Deploy-IoTEdge -ContainerOs Windows
# Define Variables for the configuration of the edge device using DPS with X509 Certificates
# Note that only .cert and .pem extensions are supported
# The names of the certificates mentioned here are the one's created using the microsoft provided scipt on github.
# The link to the github repossitory is https://github.com/Azure/iotedge/tree/master/tools/CACertificates
$X509IdentityChainCertPath = "<path to the device identity chain cert>\certs\iot-edge-device-identity-<name>-full-chain.cert.pem"
View ipsecurityarmtemplate.json
{
"apiVersion": "2015-08-01",
"name": "[variables('webSiteName')]",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"tags": {
"[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]":"Resource",
"displayName": "Website"
},
"dependsOn": [
@neerajks77
neerajks77 / CreateServicePrincipal.ps1
Last active Nov 29, 2020
This script will create the service principal in Azure AD and will be used for Azure Automation
View CreateServicePrincipal.ps1
#This function creates an Azure AD Service Principal
function CreateServicePrincipal {
param($username, $password)
$credproperties = @{
StartDate = Get-Date
EndDate = Get-Date -Year 2024
Password = $password
}
$cred= New-Object Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential -Property $credproperties
@neerajks77
neerajks77 / InitiateWatcherProcess.ps1
Last active Apr 27, 2021
This PowerShell is invoked when a new file is uploaded to the blob container. It gets the data and passes on to the other PowerShell for deployment of virtual machine. This approach has been taken to make the code more modular.
View InitiateWatcherProcess.ps1
$Creds = Get-AutomationPSCredential -Name 'Creds'
$TenantID = Get-AutomationVariable -Name 'TenantID'
Connect-AzAccount -ServicePrincipal -Credential $Creds -Tenant $TenantID
$vResourceGroupname = "atcsl"
$vAutomationAccountName = "atcslautomation"
$vaStorageAccount = Get-AutomationVariable -Name "StorageAccount"
@neerajks77
neerajks77 / CreateVirtualMachineActionRunbook.ps1
Last active Apr 27, 2021
This PowerShell script creates virtual machine(s) based on the inputs from the excel file uploaded to the storage account and is invoked by a watcher runbook
View CreateVirtualMachineActionRunbook.ps1
param([string[]] $vmdetail)
#Fetch the automation service principal credentials
$global:spCred = Get-AutomationPSCredential -Name 'Creds'
#Fetch tenantID from Automation variables
$global:tenantid = Get-AutomationVariable -Name 'TenantID'
#Fetch tenantID from Automation variables
$global:vnet = Get-AutomationVariable -Name 'vNet'