Skip to content

Instantly share code, notes, and snippets.

Anton Staykov astaykov

Block or report user

Report or block astaykov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
function check_directory_dependencies() {
echo "Checking for graph extension on Azure CLI..."
echo "--------------------------------------------"
string=$(az extension list | grep 'resource-graph')
if [[ $string == *"resource-graph"* ]];
# az extension update --name resource-graph
echo 'Graph extension is already installed...'
View LDAP_Sample_Queries
// basically gets all data about organization
ldapsearch -x -h fqdn.of.the.domain -D "upn" -w "password" -b 'dc=idcxp,dc=site'
// get data about single user object
// make sure you get the DN correct
ldapsearch -x -h fqdn.of.the.domain -D "upn" -w "password" -b 'CN=bdm-user bdmou,OU=AADDC Users,DC=idcxp,DC=site'
astaykov / CopyFromMcd.ps1
Created May 2, 2017
Copy VHDs for VMs in Microsoft Cloud Deutschalnd to any other Azure location
View CopyFromMcd.ps1
[String] $destinationUri = "https://[YOUR STORAGE ACCOUNT NAME]",
[String] $destinationKey = "[YOUR STORAGE ACCOUNT KEY]",
[String] $sourceAccountPattern = "*disk*",
[String] $pathToAzCopy = "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe"
Login-AzureRmAccount -EnvironmentName AzureGermanCloud
$storageAccounts = Get-AzureRmStorageAccount
astaykov / GetAzureVnetGateways.ps1
Last active Nov 8, 2016
Get the type of all Azure Virtual Network Gateways in your Azure subscriptions
View GetAzureVnetGateways.ps1
$subs = Get-AzureRmSubscription
ForEach ($sub in $subs)
Write-Host 'ARM: VPN Gateways in subscription' $sub.SubscriptionName '(' $sub.SubscriptionId ')'
Select-AzureRmSubscription -SubscriptionName $sub.SubscriptionName -OutVariable out
$gwr = Find-AzureRmResource -ResourceType "Microsoft.Network/virtualNetworkGateways"
if ( $gwr -ne $null)
View GetErronousAzureLoigcAppConnections.ps1
$errConnections = Get-AzureRmResource -ResourceGroupName RG-Development `
-ResourceType "Microsoft.Web/connections" -ExpandProperties |
Where-Object { $_.Properties.Statuses.Status -eq "Error" }
View DeleteAadObject.ps1
Function DeleteUser
[String] $token,
[String] $upn
$headers = @{"Authorization" = "Bearer $($token)"; "Content-Type" = "application/json"}
$deleteUserUri = "<your.tenant.domain>/users/$($upn)?api-version=1.5"
$userDeleteResult = Invoke-WebRequest -Uri $deleteUserUri -Headers $headers -Method Delete
View PromoteServicePrincipal.ps1
# Get Service Principal to add the role to
$sp = Get-MsolServicePrincipal -ServicePrincipalName "<URI_OF_YOUR_AZURE_AD_APP>"
# Get role object ID
# Alternatively, you can list all the roles (in order to get a different role name) using just `Get-MsolRole`
$roleId = (Get-MsolRole -RoleName "Company Administrators").ObjectId
# Add role to service principal
astaykov / UpdateUser.ps1
Created Oct 29, 2015
Update user properties in Azure AD Graph API
View UpdateUser.ps1
Function UpdateUser
[String] $token
$headers = @{"Authorization" = "Bearer $($token)"; "Content-Type" = "application/json"}
$updateUserUri = ""
$updateBody = @"
"department":"Super Devs"
View GetAllUsersWithToken.ps1
Function GetToken
[String] $authority = "<your_tenant>/oauth2/token",
[String] $clientId = "<client_id>",
[String] $clientSecret = "<client_secret>",
[String] $resourceId = ""
$body = "grant_type=client_credentials&resource=$($resourceId)&client_id=$($clientId)&client_secret=$($clientSecret)"
astaykov / GetToken.ps1
Created Oct 29, 2015
Get access token from Azure AD OAuth 2.0 endpoint
View GetToken.ps1
Function GetToken
[String] $authority = "",
[String] $clientId = "<your_client_id_here>",
[String] $clientSecret = "<client_secret>",
[String] $resourceId = ""
$body = "grant_type=client_credentials&resource=$($resourceId)&client_id=$($clientId)&client_secret=$($clientSecret)"
You can’t perform that action at this time.