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
| # Declaring the local variables | |
| locals { | |
| storageAccountName = lower(join("", ["sawinvm", random_string.asaname-01.result])) | |
| nicName = "myVMNic" | |
| addressPrefix = "10.0.0.0/16" | |
| subnetName = "Subnet" | |
| subnetPrefix = "10.0.0.0/24" | |
| publicIPAddressName = "myPublicIP" | |
| vmName = "SimpleWinVM" | |
| virtualNetworkName = "MyVNET" |
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
| provider "azurerm" { | |
| version = "=1.36.0" | |
| } | |
| variable "resourceGroupName" { | |
| type = string | |
| description = "Resource Group for this deployment." | |
| } | |
| variable "location" { |
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 Install-Terraform | |
| { | |
| # Ensure to run the function with administrator privilege | |
| if (-not (New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) | |
| { Write-Host -ForegroundColor Red -Object "!!! Please run as Administrator !!!"; return } | |
| # Terrafrom download Url | |
| $Url = 'https://www.terraform.io/downloads.html' | |
| # Local path to download the terraform zip file |
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 total memory in GB from the local computer using the calculated property with Select-Object | |
| Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -Property PSComputerName, ` | |
| @{Name = 'Memory in GB'; Expression = {[Math]::Round($_.TotalVisibleMemorySize/1MB)}} | |
| <# Output | |
| PSComputerName Memory in GB | |
| -------------- ------------ | |
| Workstation 8 | |
| #> |
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
| # Converts Object properties to HashTable. | |
| Function Convert-ObjectToHashTable | |
| { | |
| [CmdletBinding()] | |
| param | |
| ( | |
| [parameter(Mandatory=$true,ValueFromPipeline=$true)] | |
| [pscustomobject] $Object | |
| ) | |
| $HashTable = @{} |
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 Get-Inventory | |
| { | |
| [CmdLetBinding()] | |
| Param | |
| ( | |
| [Parameter(Mandatory=$true,ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] | |
| [string[]] $ComputerName | |
| ) | |
| Begin |
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
| # Login to your Azure Subscription | |
| #az login | |
| # Declare variables | |
| resourceGroupName='LINUX-RG' | |
| vmName='ubuntu01' | |
| # Get VM OS disk name | |
| vmdiskname=$(az vm show --resource-group $resourceGroupName --name $vmName -d --query "storageProfile.osDisk.name" -o tsv) |
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
| <# | |
| This script pulls the date and the time on which the Azure VM(s) created. | |
| This script accepts Resource Group & VM Name as mandatory parameters and accepts VM object(s) optionally. | |
| Since there is no direct Cmdlet to fetch the create date, it is considered the disk create date as VM create date. | |
| #> | |
| Function Get-AzVMCreateDate | |
| { | |
| [CmdletBinding()] | |
| param | |
| ( |
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 Get-WinSrvFromInv | |
| { | |
| <# | |
| The purpose of this function is to retrieve the list of servers for which you want to check the Windows Activation status. | |
| Write your piece of code to retirve the servers from your inventory. | |
| for example, Get-Content -Path $InvPath\Server.txt | |
| #> | |
| return @("Srv2K19", "Srv2K16", "Srv2K12") | |
| } | |
| Function Get-WindowsActivation |