Skip to content

Instantly share code, notes, and snippets.

View nickadam's full-sized avatar

Nick Vissari nickadam

View GitHub Profile
@nickadam
nickadam / create_keypair.sh
Created July 29, 2021 17:35
Create self-signed keypair with no prompts, 2048, 15 years
#!/bin/bash
name=$1
if [ -z $name ]
then
name="self-signed"
fi
openssl req -x509 -days 5479 -nodes -newkey rsa:2048 -keyout $name.key -out $name.pem -config <( cat << EOF
[ req ]
default_bits = 2048
@nickadam
nickadam / Get-MessageTraceAll.ps1
Created August 5, 2021 13:45
Get all message trace results using page feature between two dates
function Get-MessageTraceAll {
param($StartDate, $EndDate)
$Page = 1
$PageSize = 5000
$Messages = Get-MessageTrace -PageSize $PageSize -Page $Page -StartDate $StartDate -EndDate $EndDate
$Messages
while(($Messages | measure).count -gt 0){
$Page++
$Messages = Get-MessageTrace -PageSize $PageSize -Page $Page -StartDate $StartDate -EndDate $EndDate
$Messages
@nickadam
nickadam / BreachNotificationModule.ps1
Last active January 26, 2023 23:18
Send breach notifications to AD Users that have not changed their password since a breach was reported
function Find-EnabledADUser(){
<#
.SYNOPSIS
Finds a single enabled AD user for a given email address
.DESCRIPTION
Searches through the default domain or each domain given in ADDomains for a single enabled user. The user could match on EmailAddress ProxyAddresses or SamAccountName. Warns if no results or more that one result per email address.
.EXAMPLE
Find-EnabledADUser -ADDomains "example.com", "child.example.com" -Email "[email protected]"
#>
Param(
@nickadam
nickadam / check_google_urls.js
Created December 9, 2021 18:25
Login to google workspace and check if links in csv are accessible
'use strict'
const fs = require('fs')
const puppeteer = require('puppeteer')
const parse = require('csv-parse')
const import_csv = file => {
return new Promise((resolve, reject) => {
const parser = parse({}, (err , data) => {
@nickadam
nickadam / Install-Salt-Minion.ps1
Created December 19, 2021 00:20
Download and install salt-minion on windows
function Install-SaltClient(){
$FolderPath = "C:\ProgramData\SaltClient"
$FileName = "Salt-Minion-3004-2-Py3-AMD64.msi"
$Installer = $FolderPath + "\" + $FileName
$URL = "https://mywebserver.example.com/public/" + $FileName
$Hash = "11DE07BA38CA2B65B168237CA2485B1983A151528242C7BF81EC04A94660C0E8"
$SaltMaster = "mysaltmaster.example.com"
# Make Folder for tracking install
if(-not (Test-Path $FolderPath)){
@nickadam
nickadam / include_files_powershell_lambda.md
Last active February 16, 2022 12:30
Include arbitrary files in a PowerShell lambda

Include arbitrary files in a PowerShell lambda

Prerequisites

  • powershell core
  • aws cli
  • Install-Module AWSLambdaPSCore -Scope CurrentUser
  • Install-Module -Name AWS.Tools.Installer -Scope CurrentUser (only if using AWS modules)
  • Install-AWSToolsModule -Name Common (only if using AWS modules)
  • lambda execution role
@nickadam
nickadam / install_local_powershell_module_example.ps1
Created January 28, 2022 19:33
Install a powershell module locally
# Make a local repository to "publish" and "install" from
$PSRepository = (Join-Path -Path $HOME -ChildPath 'PSRepository')
mkdir $PSRepository
Register-PSRepository -Name 'local' -SourceLocation $PSRepository -PublishLocation $PSRepository -InstallationPolicy Trusted
# Make a module
mkdir .\MyModule
New-Item .\MyModule\Mine.psm1
New-ModuleManifest .\MyModule\Mine.psd1 -RootModule Mine.psm1 -Description 'MyModule'
@nickadam
nickadam / Rijndael256.ps1
Created April 2, 2022 14:10
Decrypt Rijndael 256 blocks in PowerShell Core with BouncyCastle
$Key = "SomeKey"
$IV = "SomeIV"
$CipherText = "eeXS+8jW/xrgFFeWdykzm0t8F6pmbuQwjU2uLfqJA+KyLaozbzkJ5zkpzmREA2XevE87kJXaisRDFJNeXkg+Lw=="
# Base64 CipherText to ByteArray
$CipherBytes = [System.Convert]::FromBase64String($CipherText) -As [byte[]]
# Get the Bytes of the Key and IV
$KeyBytes = [System.Text.Encoding]::UTF8.GetBytes($Key)
$IvBytes = [System.Text.Encoding]::UTF8.GetBytes($Iv)
@nickadam
nickadam / ConvertTo-RawDataEmail.ps1
Created April 25, 2022 13:37
Format raw data email message for sending attachments with AWS Send-SES2Email
function ConvertTo-RawDataEmail {
<#
.SYNOPSIS
Format an email message for AWS Send-SES2Email -Raw_Data
.DESCRIPTION
Accepts From, To, Cc, Bcc, Subject, Body, and Attachments, uses
System.Net.Mail to format the message into a byte array that
Send-SES2Email -Raw_Data can accept.
.PARAMETER From
[String] Sender's email address
@nickadam
nickadam / google_edu_tos.txt
Created September 28, 2022 14:21
Google Workspace for Education Terms of Service
Google Workspace for Education Terms of Service
Last modified: September 20, 2022
For translations of this Agreement into other languages, please click here.
If you signed an offline variant of this Agreement for use of the Google Workspace for Education Services under the same Google Workspace for Education Account, the terms below do not apply to you and your offline terms govern your use of the Google Workspace for Education Services.
If your billing account is in Brazil, please review these Terms of Service, which apply to your use of Google Workspace for Education.
Se a sua conta para faturamento é no Brasil, por gentileza veja o Termos de Serviço, que será o Termo aplicável à sua utilização da Google Workspace for Education.