Skip to content

Instantly share code, notes, and snippets.

View encryptvmss.ps1
$KVRGname = 'PixelRobots-KV-UKS';
$VMSSRGname = 'PixelRobots-VMSS-UKS';
$VmssName = 'pixelrobotsvmss';
$KeyVaultName = 'PixelRobots-VMSS-KV-UKS';
## Do not edit below this line.
$KeyVault = Get-AzKeyVault -VaultName $KeyVaultName -ResourceGroupName $KVRGname;
$DiskEncryptionKeyVaultUrl = $KeyVault.VaultUri;
$KeyVaultResourceId = $KeyVault.ResourceId;
Set-AzVmssDiskEncryptionExtension -ResourceGroupName $VMSSRGname -VMScaleSetName $VmssName -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $KeyVaultResourceId;
View AzureSubscriptionRBACAudit.ps1
#requires -Version 3.0 -Modules Az.Resources
param(
[switch]
$email
)
$ErrorActionPreference = 'Stop'
## Email Style
View azure disk alert
// enter a GB value to check
let setgbvalue = 100;
// Query
Perf
| where TimeGenerated > ago(1h)
| where ObjectName == "LogicalDisk" and CounterName == "Free Megabytes"
| where InstanceName !contains "D:"
| where InstanceName !contains "_Total"
| extend FreeSpaceGB = CounterValue/1024
| summarize FreeSpace = min(FreeSpaceGB) by Computer, InstanceName
View AzureSubscriptionSelector.ps1
function Login {
$needLogin = $true
Try {
$content = Get-AzContext
if ($content) {
$needLogin = ([string]::IsNullOrEmpty($content.Account))
}
}
Catch {
if ($_ -like "*Login-AzAccount to login*") {
View domjoin.tf
resource "azurerm_virtual_machine_extension" "domjoin" {
name = "domjoin"
location = "${var.location}"
resource_group_name = "${var.image_resource_group}"
virtual_machine_name = "${var.prefix}"
publisher = "Microsoft.Compute"
type = "JsonADDomainExtension"
type_handler_version = "1.3"
# What the settings mean: https://docs.microsoft.com/en-us/windows/desktop/api/lmjoin/nf-lmjoin-netjoindomain
settings = <<SETTINGS
View Azure Security Center Preview Cmdlets.ps1
Install-Module PowerShellGet –Repository PSGallery –Force
Install-Module -name AzureRM.Profile -requiredversion 5.5.0
Install-Module -Name AzureRM.Security -AllowPrerelease
Import-Module AzureRM.Profile -RequiredVersion 5.5.0
Import-Module AzureRM.Security
View AKS_part1.ps1
az aks get-credentials --resource-group PixelContainers --name PixelCluster
kubectl get nodes
az aks install-cli
az login
az aks get-credentials --resource-group PixelContainers --name PixelCluster
View Azure_Run_Command.ps1
Invoke-AzureRmVMRunCommand -ResourceGroupName '<myResourceGroup>' -Name '<myVMName>' -CommandId 'RunPowerShellScript' -ScriptPath '<pathToScript>' -Parameter @{"arg1" = "var1";"arg2" = "var2"}
View Bulkadd_AZ_DNS.PS1
#Bulk Import A Records
Import-CSV -Path "C:\scripts\arecords.csv" | ForEach-Object { New-AzureRmDnsRecordSet -Name $_.Name -RecordType $_.RecordType -ZoneName $_.ZoneName -ResourceGroupName $_.ResourceGroupName-Ttl $_.TTL -DnsRecords (New-AzureRmDnsRecordConfig -IPv4Address $_.Value) }
#Bulk Import CNAME Records
Import-CSV -Path "C:\scripts\cnamerecords.csv" | ForEach-Object { New-AzureRmDnsRecordSet -Name $_.Name -RecordType $_.RecordType -ZoneName $_.ZoneName -ResourceGroupName $_.ResourceGroupName-Ttl $_.TTL -DnsRecords (New-AzureRmDnsRecordConfig -Cname $_.Value) }
View Azure_locks.ps1
#Resource Lock
$LockName = "LockCloudWitnes"
$ResourceName = "pixelcloudwitness"
$ResourceType = (Get-AzureRmResource -Name $ResourceName).resourcetype
$RGName ="PIXELLAB"
New-AzureRmResourceLock -LockLevel CanNotDelete -LockName $LockName -ResourceName $ResourceName -ResourceType $ResourceType -ResourceGroupName $RGName
#Resource Group Lock
$LockName = "PIXELLABLock"
$RGName ="PIXELLAB"
You can’t perform that action at this time.