Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vijayjt
vijayjt / hdinsight-standard-pam-configuration.sh
Created October 3, 2017 16:04
Reset PAM configuration on HDInsight
echo 'H4sIACqlxVgAA5VUyW7bMBA9218xiA9JANtpeigKFDnkAwoEaG9FEYzFkT0xRapc7Khf30dKNrK0
h54Mk5w3b5nRYr6gG0nNTc/d2tw0vuu8W3HT+OwSrYhz2vmgvzmpdxQlJXXbSOM7Sp7YWhyHgzYS
5wugfd9ppFatEH7VNTYbMdQG35FPOwmn16vYS6OtNvRw/xWArtVtrYtLoLAzFHc+W1OuEqsjJqsx
kW8JMG+Idd5kVOKGExlp1QlAyrtGXApsCZIkRuq91Wag1gfKUahowKM4xCTdmkBeSjlnmwr95IHi
nR1w6IYT8yIbxSHScecBMrkViYOQPPcaIBiEq69xx8Yf19Wa+1jYw2m6XX9Y364+LdH9hVsdO96i
djOUR6sicZV7w0nK0cRrXTz2lHiPzubAMGcroysal6SVeJCSkLhiffVk8HnyOIMkuwEo1jcw5mSd
aE1nI/AGeIG4TfifXjiyQcV+WbOBfiC8ZQljRg2wykpTowGzMfepEVz+Jn8pvvp8XWMxgrRtLI7h
EQql+lp49BJWPTf70uBE+6pcXDwE7TgMFyPF6/kUyexHzDX3u4/k5PhY2iW/fwzyy9wZ787S7nTr
IPvnDKQes9PndfT0HuX2P1CO6jbqTAUadVzGqqLFymyggrQl5ychVFuIieemQM8aNclsVvHKBAKs
@vijayjt
vijayjt / hdinsight-ambari-examples.sh
Last active October 3, 2017 15:19
HDInsight Ambari REST API examples - check out my repo AzureHDInsight for the full code
function check_ambari_user_exists()
{
USER_TO_CHECK=$1
# Get list of users in Ambari
USER_LIST=$(curl -u "$USERID:$PASSWD" -sS -G "http://${ACTIVEAMBARIHOST}:8080/api/v1/users" | grep 'user_name' | cut -d":" -f2 | tr -d '"','',' ' )
for User in $( echo "$USER_LIST" | tr '\r' ' '); do
echo "-${User}-"
if [ "$User" == "$USER_TO_CHECK" ];then
echo 0
@vijayjt
vijayjt / create-azure-ad-app-and-spn-multiple-certs.ps1
Last active October 2, 2017 17:18
Create an Azure AD App with Multiple Certs for Authentication
Login-AzureRmAccount
# Create the self signed cert
mkdir c:\certificates
$currentDate = Get-Date
$endDate = $currentDate.AddYears(1)
$notAfter = $endDate.AddYears(1)
$pwdplaintext = "P@ssW0rd1"
@vijayjt
vijayjt / Get-AzureRegionPublicIPAddressList.ps1
Created May 21, 2017 09:47
The function lists the public IP addresses in a particular Azure region
Function Get-AzureRegionPublicIPAddressList
{
<#
.SYNOPSIS
The function lists the public IP addresses in a particular Azure region
.DESCRIPTION
The function lists the public IP addresses in a particular Azure region.
.PARAMETER Region
The Azure region for which you want to retrieve public IP addresses.
.PARAMETER AzureIPRangeXMLFile
@vijayjt
vijayjt / Get-AzurePubicIpXMLRegionList.ps1
Last active May 21, 2017 10:02
Return the regions in the Azure Public IP XML file
Function Get-AzurePubicIpXMLRegionList
{
<#
.SYNOPSIS
The function takes the Azure Public IP address XML file and returns an array of region names
.DESCRIPTION
The function takes the Azure Public IP address XML file and returns an array of region names
.PARAMETER AzureIPRangeXMLFile
The XML file containing the Azure IP ranges.
.EXAMPLE
@vijayjt
vijayjt / Get-AzureIPRangesXMLFile.ps1
Last active July 31, 2017 12:25
PowerShell function to download the Azure Public IP Ranges file and save it locally
Function Get-AzurePublicIPRangesXMLFile
{
<#
.SYNOPSIS
This function downloads the Azure IP ranges XML file to the current directory or a specified path.
.DESCRIPTION
This function downloads the Azure IP ranges XML file to the current directory or a specified path.
.PARAMETER AzureIPRangeURL
An optional parameter that is the URL to the Azure IP range XML file download page.
.PARAMETER DestinationPath
@vijayjt
vijayjt / azure-web-app-php-ldap-test.php
Created April 10, 2017 19:47
Code for testing LDAP connection from an Azure Web App in an ASE to a AD DC in a VNet
<?php
$domain = 'acme.local';
$username = 'aduser';
$password = 'replaceWithPassword';
$ldapconfig['host'] = '192.168.21';
$ldapconfig['port'] = 389;
$ldapconfig['basedn'] = 'dc=acme,dc=local';
$ldap_dn = "DC=acme,DC=local";
@vijayjt
vijayjt / PowerShell-LDAP-Search-Example1.ps1
Created April 10, 2017 19:42
How to search AD using PowerShell
$username = 'aduser'
$password = 'replaceWithPassword'
$DomainControllerIpAddress = '192.168.0.21'
$LdapDn = 'dc=acme,dc=local'
$dn = New-Object System.DirectoryServices.DirectoryEntry ("LDAP://$($DomainControllerIpAddress):389/$LdapDn",$username,$password)
# Here look for a user
$ds = new-object System.DirectoryServices.DirectorySearcher($dn)
$ds.filter = "((userPrincipalName=*))"
$ds.SearchScope = "subtree"
@vijayjt
vijayjt / Windows-Server2008R2-AD-Install.ps1
Created April 10, 2017 19:29
PowerShell code for installing AD and running DC Promo via an Answer file for Win2K8R2 (for ASE and AD blog post)
$AccountName = 'my-admin'
$vmpwd = 'ReplaceWithAStrongPassword'
$SecurePassword = ConvertTo-SecureString $vmpwd -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($AccountName, $SecurePassword);
Import-Module ServerManager
Add-WindowsFeature GPMC, Backup-Features, Backup, Backup-Tools,DNS,WINS-Server -Verbose
Add-WindowsFeature AS-NET-Framework -Verbose
Add-WindowsFeature AD-Domain-Services, ADDS-Domain-Controller -Verbose
@vijayjt
vijayjt / create-win2k8r2-vm-in-azure-arm.ps1
Last active April 10, 2017 19:30
PowerShell code to create a Windows Server 2008 R2 VM in Azure (for ASE and AD blog post)
# Select a subscritpion
Set-AzureRmContext -SubscriptionName (Get-AzureRmSubscription | Out-GridView -PassThru).SubscriptionName
$Location = 'North Europe'
# Create a resource group for the VM and storage account
$CoreInfraResourceGroupName = 'VM-RG-0001'
New-AzureRmResourceGroup -Name $CoreInfraResourceGroupName -Location $Location
$CoreInfraVMStorageAccount = '0048vhdstorage'