Skip to content

Instantly share code, notes, and snippets.


David O'Brien davidobrien1985

View GitHub Profile
View delete-azure-roleassignments.ps1
param (
[bool]$DeleteRoleAssignments = $false
if (-not (Get-Module -ListAvailable -Name Az)) {
Write-Output "Installing Az module..."
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
davidobrien1985 / stored-proc.js
Last active March 2, 2022 23:26
Cosmos DB Stored Procedure to update all documents based on query with a new property called inventoryStatus. Change lines 27 and 37 to create a different property.
View stored-proc.js
function addProperty(continuationToken) {
var response = getContext().getResponse();
var collection = getContext().getCollection();
var updated = 0;
if (continuationToken) { // Parse the token
var token = JSON.parse(continuationToken);
if (!token.queryContinuationToken) {
throw new Error('Bad token format: no continuation');
davidobrien1985 / create-argos-azure-spn.ps1
Last active January 17, 2022 02:53
Create an Azure Active Directory App Registration / Service Principal to be used for ARGOS Cloud Security
View create-argos-azure-spn.ps1
Create an Azure Active Directory App Registration / Service Principal to be used for ARGOS Cloud Security
This script creates an Azure Active Directory App Registration and an Application Secret that can be used to connect ARGOS Cloud Security to Microsoft Azure in order to scan Azure Subscriptions. The secret has a validity of 12 months.
Best executed in Azure Cloud Shell ( as Cloud Shell is already authenticated to your tenant. User executing this script requires permissions to create an AAD App Registration and permissions to assign IAM Roles to Azure Subscriptions.
davidobrien1985 / test.cs
Created September 11, 2021 06:46
View test.cs
public class InventoryBulkStorage : IInventoryBulkStorage
private readonly CosmosContainer _containerId = CosmosContainer.Inventory;
private readonly bool _isBulk = true;
public async Task UpsertBulkAsync(IEnumerable<InventoryResource> resources)
var containers = CosmosProvider.Containers
.Where(c => c.ContainerId == _containerId && c.IsBulk == _isBulk)
.ToDictionary(k => k.Region, v => v.Container);
davidobrien1985 / ARGOS-API-example.ps1
Created August 25, 2021 05:57
ARGOS API query example
View ARGOS-API-example.ps1
# Use for more information about browsing the API
# Go to to generate or get your personal API key
$headers = @{"Ocp-Apim-Subscription-Key"="____________________replace_________________"}
$result = Invoke-WebRequest -Headers $headers -Uri | ConvertFrom-Json
$detections = $
$openDetections = $detections | Where-Object -FilterScript {$_.status -eq "open"}
$azureDetections = $detections | Where-Object -FilterScript {$ -eq "azure"}
davidobrien1985 / policy.json
Last active June 20, 2021 07:31
ARGOS AWS IAM policy document required for ARGOS to successfully scan your AWS Accounts
View policy.json
"Version": "2012-10-17",
"Statement": [
"Effect": "Allow",
"Action": [
davidobrien1985 / test-arm-template.ps1
Created September 17, 2020 05:29
Azure ARM template test
View test-arm-template.ps1
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$body = @'
"$schema": "",
"contentVersion": "",
"parameters": {
"projectName": {
"type": "string",
davidobrien1985 / pipeline.yaml
Created February 16, 2020 05:46
azure devops pipeline example build - release
View pipeline.yaml
- master
- infra/*
- xirus/*
davidobrien1985 / arm-afd-storage.json
Last active February 9, 2020 04:56
ARM template to deploy Azure Front Door and maintenance rules
View arm-afd-storage.json
"$schema": "",
"contentVersion": "",
"parameters": {
"frontDoorName": {
"defaultValue": "davidobrien",
"type": "string"
"storageAccountName": {
"defaultValue": "davidobrienmaintenance",
davidobrien1985 / main.go
Last active May 26, 2019 11:14
requires passing in of "user" parameter, example: `go run main.go -user=davidobrien1985`
View main.go
package main
import (