Skip to content

Instantly share code, notes, and snippets.

View kpatnayakuni's full-sized avatar
🏠
Working from home

Kiran Patnayakuni kpatnayakuni

🏠
Working from home
View GitHub Profile
@kpatnayakuni
kpatnayakuni / 101-vm-simple-windows-main.tf
Created December 6, 2019 13:08
101-vm-simple-windows main configuration
# 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"
@kpatnayakuni
kpatnayakuni / 101-vm-simple-windows-variables.tf
Created December 6, 2019 12:31
101-vm-simple-windows HCL configuration Variables
provider "azurerm" {
version = "=1.36.0"
}
variable "resourceGroupName" {
type = string
description = "Resource Group for this deployment."
}
variable "location" {
@kpatnayakuni
kpatnayakuni / Install-Terraform.ps1
Created December 5, 2019 09:38
Download & Configure Terraform
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
@kpatnayakuni
kpatnayakuni / Demo-CalculatedFields.ps1
Created November 29, 2019 03:03
Calculated Properties
# 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
#>
@kpatnayakuni
kpatnayakuni / Convert-ObjectToHashTable.ps1
Last active November 26, 2019 15:23
Converts Object properties into HashTable
# Converts Object properties to HashTable.
Function Convert-ObjectToHashTable
{
[CmdletBinding()]
param
(
[parameter(Mandatory=$true,ValueFromPipeline=$true)]
[pscustomobject] $Object
)
$HashTable = @{}
@kpatnayakuni
kpatnayakuni / Sample-Inventory.ps1
Last active November 6, 2019 14:32
Inventory Sample
Function Get-Inventory
{
[CmdLetBinding()]
Param
(
[Parameter(Mandatory=$true,ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[string[]] $ComputerName
)
Begin
@kpatnayakuni
kpatnayakuni / azvmcreatedate.sh
Created September 26, 2019 04:06
Azure VM Create Date using Azure Cli
# 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)
@kpatnayakuni
kpatnayakuni / Get-AzVMCreateDate.ps1
Last active September 25, 2019 17:57
Get Azure VM Create Date
<#
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
(
@kpatnayakuni
kpatnayakuni / Get-WindowsActivationStatus.ps1
Created September 3, 2019 11:38
Get Windows Activation Status
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