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 / Connect-ExchangeOnline.ps1
Created March 1, 2016 00:07
Connects PowerShell to Office 365 Exchange Online
function Connect-ExchangeOnline() {
Param(
$Credential = $(Get-Credential)
)
if (-not $global:eoSession) {
$Global:eoSession = New-PSSession `
-ConfigurationName Microsoft.Exchange `
-ConnectionUri "https://outlook.office365.com/powershell-liveid" `
@chrisbrownie
chrisbrownie / TellMeWhenMyBlogIsBack.ps1
Created June 5, 2016 08:19
Lets you know, loudly, when a site is available
$uri = "https://flamingkeys.com"
while ($true) {
try {
Invoke-WebRequest $uri -TimeoutSec 5
start "https://www.youtube.com/watch?v=xos2MnVxe-c"
break
} catch {
@chrisbrownie
chrisbrownie / EmailWhenUp.ps1
Created August 4, 2016 04:25
Emails when a device starts replying to ICMP ping requests
#EmailWhenUp.ps1
# Usage: ./EmailWhenUp.ps1 Computer01
Param([string]$ComputerName,[string]$mailServer,[string]$MailTo)
function isup {
Param([string]$ComputerName)
Test-Connection -ComputerName $ComputerName -Count 1 -Quiet
}
@chrisbrownie
chrisbrownie / Get-AirServicesCharts.ps1
Created August 23, 2016 10:44
Downloads all DAP charts from AirServices
# Downloads all aero charts from Airservices
$hostUri = "http://www.airservicesaustralia.com/aip/current/dap/AeroProcChartsTOC.htm"
$fileTypesToDownload = @("pdf")
# Download the page of charts
$links = Invoke-WebRequest $hostUri | select -ExpandProperty links
# Get a webclient ready for downloading files
$webClient = New-Object System.Net.WebClient
foreach ($link in $links) {
@chrisbrownie
chrisbrownie / Convert-ExcelSheetToJson.ps1
Last active October 5, 2016 05:39
Converts an Excel sheet to a Json file
# Moved to Github: https://github.com/chrisbrownie/Convert-ExcelSheetToJson
@chrisbrownie
chrisbrownie / GetExchange2003DistributionGroups.vbs
Created September 19, 2016 03:42
Returns all mail-enabled groups in the domain
'======================================================================
' GetDistributionGroups.vbs
'======================================================================
' Author: Chris Brown ([email protected])
' Date: 09/10/2014
' Details: Returns all mail-enabled groups in the domain
' Source: Unknown (I forget if I wrote this myself or found it somewhere)
'======================================================================
' Everything below this will be searched. Must be in the format
@chrisbrownie
chrisbrownie / GetExchange2003SmtpAddresses.vbs
Created September 19, 2016 03:43
Returns all SMTP proxy addresses for all users in a given domain or OU in CSV format
'======================================================================
' ListAllSMTPAddresses.vbs
'======================================================================
' Author: Chris Brown ([email protected])
' Date: 07/10/2014
' Details: Returns all SMTP proxy addresses for all users in a given
' domain or OU in CSV format
' Source: Unknown (I forget if I wrote this myself or found it somewhere)
'
'
@chrisbrownie
chrisbrownie / Get-RandomPhoneNumber.ps1
Created September 19, 2016 03:45
Generates a random phone number (completely random, not necessarily a valid one)
function Get-RandomNumber ([int]$min,[int]$max,[switch]$leadingZeroes) {
$number = Get-Random -Minimum $min -Maximum $max
if ($leadingZeroes) {
if ($number.ToString().Length -lt $max.ToString().Length) {
$number.Tostring().PadLeft($max.ToString().Length,"0")
} else {
$number.ToString()
}
} else {
$number.ToString()
@chrisbrownie
chrisbrownie / AddOrUpdateInTextFile.ps1
Created September 20, 2016 23:07
Adds or updates text between two markers in a text file.
function AddOrUpdateTextInFile() {
Param(
$File,
[string]$StartString,
[string]$EndString,
[string]$ReplacementString
)
$fileContent = Get-Content $File -ReadCount 512
@chrisbrownie
chrisbrownie / EncryptBasedOnSenderGroupMembership.ps1
Created October 6, 2016 08:17
Encrypt Messages with OME based on Sender Group Membership
New-TransportRule -Name "Encrypt mail from the Security team" `
-RuleErrorAction Defer `
-FromMemberOf '[email protected]' `
-SetAuditSeverity Low `
-ApplyOME $true