Skip to content

Instantly share code, notes, and snippets.

@chadmando
chadmando / parent.py
Last active May 19, 2021 19:07
Setting parent folder path when using src scaffolded Python projects
"""
snippet for working in a nested structure and needing to access
data folders in the parent
"""
from pathlib import Path
parent = (Path.cwd()).parent
path_to_data = parent.joinpath("path", "to", "data")
@chadmando
chadmando / getsystemlogerrors.ps1
Last active August 30, 2021 22:25
Save Error Level System Logs to a file
# Get all System Log Events that are "Error" or "Critical" level and
# save to an xml file (deserialize)
$filter = @{LogName="System"; Level=(1,2)}
Get-WinEvent -Filterhashtable $filter |
Export-CliXml -Path "$ENV:USERPROFILE\system_errors.xml"
@chadmando
chadmando / ohmyposhv3-v2.json
Created September 2, 2021 14:17 — forked from shanselman/ohmyposhv3-v2.json
ohmyposhv3-v2
{
"final_space": true,
"console_title": true,
"console_title_style": "folder",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 0,
@chadmando
chadmando / brew-install-script.sh
Last active September 17, 2021 17:33 — forked from CliffordAnderson/brew-install-script.sh
Brew script for installing packages and applications on OSX
#!/bin/sh
# Homebrew Script for OSX
# To execute: save and `chmod +x ./brew-install-script.sh` then `./brew-install-script.sh`
echo "Installing brew..."
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo "Installing brew cask..."
brew tap homebrew/cask
@chadmando
chadmando / EventID10016_XML_Filter.txt
Created October 8, 2021 16:10
XML Filter for removing Distributed COM Errors in Windows Event Viewer
<!-- XML Query Filter copied from
https://docs.microsoft.com/en-us/troubleshoot/windows-client/application-management/event-10016-logged-when-accessing-dcom
-->
<QueryList>
<Query Id="0" Path="System">
<Select Path="System">*</Select>
<Suppress Path="System">
*[System[(EventID=10016)]]
@chadmando
chadmando / smartsheet_python_examples.py
Created December 30, 2021 21:04
Python Smartsheet SDK Examples for my use cases
import smartsheet
API_KEY = 'Insert you API Key here'
smartsheet_client = smartsheet.Smartsheet(API_KEY)
# Get a list of the filters for a sheet
sheet_id = 123456789 # insert your sheet_id
sheet = smartsheet_client.Sheets.get_sheet(sheet_id, include=["filterDefinitions"])
@chadmando
chadmando / get-quarantinedmessages.ps1
Created February 23, 2022 17:04
Find all quarantined messages from the last week for all users. Results are grouped by users to make finding messages for specific users easier.
# Must be connected to Exchange Online
# Gets all Quarantined messages from the last week
# Results are grouped by recipient
Get-MessageTrace -EndDate (Get-Date) -StartDate (Get-Date).adddays(-7) -Status Quarantined |
Sort-Object -Property RecipientAddress |
Format-Table -GroupBy RecipientAddress
@chadmando
chadmando / powershell-web-server.ps1
Created February 28, 2022 22:30 — forked from 19WAS85/powershell-web-server.ps1
A simple web server built with powershell.
# This is a super **SIMPLE** example of how to create a very basic powershell webserver
# 2019-05-18 UPDATE — Created by me and and evalued by @jakobii and the comunity.
# Http Server
$http = [System.Net.HttpListener]::new()
# Hostname and port to listen on
$http.Prefixes.Add("http://localhost:8080/")
# Start the Http Server
# one-liner to copy text files in a directory and change the year from 2021-> 2022 in the file name.
# change file extension to suit
dir *.txt |
select -expandproperty fullname |
Copy-Item -Path $_ -Desination ($_).replace("2021","2022")
# requires EXO V2
Get-ExoMailbox -PropertySets Quota -RecipientTypeDetails Usermailbox |
Select-Object -Property Identity,ProhibitSendQuota, ProhibitSendReceiveQuota, IssueWarningQuota |
Format-Table