Skip to content

Instantly share code, notes, and snippets.

View chrisbrownie's full-sized avatar
🛩️
computering

Chris Brown chrisbrownie

🛩️
computering
View GitHub Profile
@chrisbrownie
chrisbrownie / DisablePasswordWriteback.ps1
Created February 1, 2017 04:10
Disable AAD Connect Password Writeback
Import-Module ADSync
$connector = (Get-ADSyncConnector | Where-Object {$_.Name -ilike "*AAD"}).Name
Get-ADSyncAADPasswordResetConfiguration -Connector $connector
Set-ADSyncAADPasswordResetConfiguration -Connector $connector -Enable:$false
@chrisbrownie
chrisbrownie / EnablePasswordWriteback.ps1
Last active February 1, 2017 23:18
Enable AAD Connect Password Writeback
Import-Module ADSync
$connector = (Get-ADSyncConnector | Where-Object {$_.Name -ilike "*AAD"}).Name
Get-ADSyncAADPasswordResetConfiguration -Connector $connector
Set-ADSyncAADPasswordResetConfiguration -Connector $connector -Enable:$true
@chrisbrownie
chrisbrownie / Get-MailboxItemsByClass.ps1
Created April 3, 2017 03:26
Returns a count of mailbox items of the specified class.
<#
.SYNOPSIS
Get-MailboxItemsByClass.ps1 - Returns a count of mailbox items of the specified class.
.DESCRIPTION
This function will return a count of the number of items in a mailbox matching the specified class.
Uses EWS Managed API to perform the check
.EXAMPLE
.\Get-MailboxItemsByClass.ps1 -MailboxToSearch [email protected] -ItemStubClass IPM.Note -StoredCredentialUsername [email protected]
.LINK
https://flamingkeys.com/
# Alert whenever the free space on disk falls below the following factor
# .20 = 20 %
# .10 = 10 %
$alarmThreshold = ".20"
$pushoverUrl = "https://api.pushover.net/1/messages.json"
$pushoverToken = ""
$pushoverUserKey = ""
@chrisbrownie
chrisbrownie / Compare-FileToHash.ps1
Last active January 11, 2022 04:24
Compares a file to a given hash
function Compare-FileToHash {
<#
.SYNOPSIS
Compare-FileToHash - Compares a file to a given hash and returns a boolean of whether they match or not
.DESCRIPTION
This function will compare a file to a given hash (in string format) and
returns the boolean $true or $false depending on whether the hashes match.
Supported algorithms are all those supported by Get-FileHash.
.EXAMPLE
@chrisbrownie
chrisbrownie / vscode-settings.json
Last active July 13, 2017 03:04
My VS Code settings
// Place your settings in this file to overwrite the default settings
{
"window.zoomLevel": 1,
"editor.fontSize": 12,
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.cursorStyle": "line",
"editor.cursorBlinking": "phase",
"editor.renderLineHighlight": "all",
"editor.renderIndentGuides": true,
<#
.SYNOPSIS
Copies Word Custom Document Properties from one document to another
.DESCRIPTION
Given two word documents (a source and a target), this script will copy all
custom document properties from the source document to the target document.
Document properties that already exist in the target document will remain
untouched.
@chrisbrownie
chrisbrownie / Get-PublicS3Buckets.sh
Created July 10, 2017 01:05
Returns all publicly accessible S3 buckets to which the executor has access to view the ACL
#!/bin/bash
EMPTYGRANTS='{"Grants":[]}'
buckets=`aws s3api list-buckets --output json | jq -r '.Buckets[].Name'`
for bucket in $buckets; do
acl=`aws s3api get-bucket-acl --bucket $bucket --output json | jq -c 'del(.Owner) | .Grants |= map( select(.Grantee.URI == "http://acs.amazonaws.com/groups/global/AllUsers") )'`
#!/bin/bash
# Number of days old an access key is allowed to be
ACCESS_KEY_MAX_AGE=90
# Get every user's username
users=`aws iam list-users | jq -r '.Users[] | .UserName'`
# Get the oldest Created Date that we can allow (now minus ACCESS_KEY_MAX_AGE days)
created_date_limit=`date -d "-$ACCESS_KEY_MAX_AGE days" +%s`
@chrisbrownie
chrisbrownie / OnlyWithValues.ps1
Created August 3, 2017 05:40
Returns only properties that have values
function OnlyWithValues {
PROCESS {
$properties = $_ | Get-Member | Select -ExpandProperty Name
$output = @{}
foreach ($property in $properties) {
if (-not ([String]::IsNullOrEmpty($_.$property))) {
$output[$property] = $_.$Property
}
}
return $output