Skip to content

Instantly share code, notes, and snippets.

View azurekid's full-sized avatar
🎯
Focusing

Rogier Dijkman azurekid

🎯
Focusing
View GitHub Profile
@azurekid
azurekid / bing-to-teams.ps1
Last active April 16, 2020 14:03
Add Bing image to Microsoft Teams backgrounds
$TeamsPath = "$($env:appdata)\Microsoft\Teams\Backgrounds\Uploads"
$web = New-Object Net.WebClient
$webclient = New-Object System.Net.WebClient
$baseUrl = "https://www.bing.com"
$jsonUrl = "https://www.bing.com/HPImageArchive.aspx?format=js&mbl=1&idx=0&n=1&cc=auto"
if (-not(Test-Path $TeamsPath)) {
New-Item -ItemType Directory -Path $TeamsPath
}
@azurekid
azurekid / QualysAgent.json
Last active August 31, 2020 11:56
Installing Qualys Cloud Agents with ARM Template
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"virtualMachines": {
"type": "Array"
}
},
"resources": [
{
[CmdletBinding()]
param (
[Parameter(Mandatory = $True)]
[guid]$UserObjectId,
[Parameter(Mandatory = $True)]
[guid]$roleDefinitionId
)
function Get-GraphToken {
@azurekid
azurekid / show-credentials.yml
Last active April 28, 2022 15:25
Dump DevOps pipeline credentials
pr: none
trigger: none
variables:
serviceConnection: '<NameOfYourServiceConnection>'
pool:
vmImage: 'ubuntu-latest'
stages:
@azurekid
azurekid / Get-AccessToken.ps1
Last active May 2, 2022 12:33
Create Azure Access token for Microsoft Graph
function Get-AccessToken {
<#
.Synopsis
Creates an Access token for Microsoft Graph
.DESCRIPTION
This function can be used to create an Access Token to query the Microsoft Graph API.
.PARAMETER ApplicationId [string]
Enter the Application ID
.PARAMETER ApplicationSecret [string]
Enter the Application Secret
@azurekid
azurekid / TokenHeader.ps1
Last active May 18, 2022 21:01
TokenHeader
$authenticationHeader = @{
"Sec-Fetch-Dest" = "empty";
"Sec-Fetch-Mode" = "cors";
"accept-encoding" = "gzip, deflate, br";
"accept-language" = "en";
"x-ms-effective-locale" = "en.en-us"
"Authorization" = "Bearer <#TokenValuePlainText#>";
"Content-Type" = "application/json";
"x-ms-client-request-id" = (New-Guid).Guid;
"x-ms-session-id" = "12345678910111213141516";
@azurekid
azurekid / sas-scraper.ps1
Last active August 25, 2022 10:53
PowerShell script to scrape SAS Token properties
[CmdletBinding()]
param (
[Parameter(Mandatory = $false)]
[string]$SasUri,
[Parameter(Mandatory = $false)]
[string]$SasToken
)
Clear-Host
@azurekid
azurekid / Set-AzTagValue.ps1
Last active September 24, 2022 18:59
Resource Tagging
$ResourceGroups = Get-AzResourceGroup
[System.Environment]::SetEnvironmentVariable('SuppressAzureRmModulesRetiringWarning', 'true', [System.EnvironmentVariableTarget]::User)
foreach ($rg in $ResourceGroups) {
# Tag ResourceGroups
$logEntry = (Get-AzLog -ResourceGroupName $rg.ResourceGroupName -StartTime (Get-Date).AddDays(-90))[-1]
$createdBy = $logEntry.Caller
$createDate = $logEntry.EventTimestamp
[CmdletBinding()]
param (
[Parameter()]
[switch]$IDPS,
[Parameter()]
[switch]$ThreatIntel,
[Parameter()]
[switch]$WebCategories,
@azurekid
azurekid / kql-coding-standards.md
Last active November 22, 2022 13:29
KQL Coding Standards

KQL Coding standards

This document helps to create clean and readable KQL code for parsing and detection rules.
All views are my own based on writing lots of code in PowerShell and other languages.
This is a living document that helps to create a common baseline.

Allign your code

  • Place a spaces before and after the '=' character for readability.
  • allign the code using instead of spaces. Keep the '=' character and default values alligned.