Skip to content

Instantly share code, notes, and snippets.

View briglx's full-sized avatar

Brig Lamoreaux briglx

View GitHub Profile
@briglx
briglx / extract.py
Last active May 7, 2024 11:24
Extract Email from Outlook with Python
#!/usr/bin/python
"""Script to fetch email from outlook."""
import win32com.client
def extract(count):
"""Get emails from outlook."""
items = []
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6) # "6" refers to the inbox
@briglx
briglx / mountNetworkShare.ps1
Last active May 19, 2016 17:22
Powershell script to mount Azure Storage File as network share
# For Details see https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-files/
# Connect to share file
# Import required modules
Import-Module myAzureStorageAccountName.file.core.windows.net
# Add key to system so network share can reconnect when system restarts
cmdkey /add:myAzureStorageAccountName.file.core.windows.net /user:myAzureStorageAccountName /pass:myAzureStorageAccountAccessKeyEndingIn==
# Create the network share
@briglx
briglx / mountNetworkShare.sh
Last active May 19, 2016 17:22
Bash script to mount Azure Storage File as network share
#!/bin/bash
# See for details https://azure.microsoft.com/en-us/documentation/articles/storage-how-to-use-files-linux/
sudo apt-get install cifs-utils
mkdir ~/myFolderName
sudo mount -t cifs //myAzureStorageAccountName.file.core.windows.net/myFileShareName ~/myFolderName -o vers=3.0,username=myAzureStorageAccountName,password=myAzureStorageAccountAccessKeyEndingIn==,dir_mode=0755,file_mode=0664
# First download an Azure Publish File
# Get-AzurePublishSettingsFile
# save the file somewhere special
#Import file
Import-AzurePublishSettingsFile \path\to\pushlish-settings-file.publishsettings
Login-AzureRmAccount
find -name "*.jpg" | gawk 'BEGIN{ a=1}{printf "mv %s %5d.jpg\n", $0, rand()*100000000}' | bash
@briglx
briglx / ListAzureVms.ps1
Created October 18, 2016 15:52
List all VM on Azure
try {
$null = Get-AzureRmSubscription
}
catch {
Login-AzureRmAccount
}
$subscriptions = Get-AzureSubscription
@briglx
briglx / parse_azure_deployment.py
Created August 24, 2017 22:58
Parse the output from a call to the azure deployment api. Usage: azure group deployment operation list --name deploymentname --resource-group rgname | python parse_azure_deployment.py
#!/usr/bin/python
import json
import sys
from pprint import pprint
import fileinput
data = json.load(sys.stdin)
for d in data:
@briglx
briglx / fetch_azure_billing_detail.ps
Created October 16, 2017 20:12
Fetch Azure Monthly Report
#!/bin/bash
# Replace the placeholders with your access token and ea number
# Replace the date with the month you are interested in YYYY-MM
wget -d --header="authorization: bearer REPLACE_WITH_ACCESS_TOKEN" --header="api-version: 1.0" -O usagereport.csv "https://ea.azure.com/rest/REPLACE_WITH_EA_NUMBER/usage-report?month=2017-10&type=detail&fmt=Csv"
@briglx
briglx / slurpBlogger.py
Last active January 29, 2019 21:54
Script to slurp blog posts from blogger
#!/usr/bin/env python3
"""Slurp all Images and text from the blog into a folder."""
from urllib.request import urlopen, urlretrieve
from bs4 import BeautifulSoup
from datetime import datetime
import os
import re
import os.path