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 / 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 / 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 / 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 / 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 / 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 / Grant-SharedMailboxPermissions.ps1
Created February 24, 2016 22:09
Grants Full Access and Send On Behalf permissions to shared mailbox for a user or distribution group members (Exchange Online)
function Grant-SharedMailboxPermissions ($mailbox,$principles) {
Get-Mailbox $mailbox | Set-mailbox -GrantSendOnBehalfTo $principles
foreach ($principle in $principles) {
switch ((Get-Recipient $principle).RecipientType.ToString()) {
"UserMailbox" {
Add-MailboxPermission -Identity $mailbox -User $principle -AccessRights fullaccess -InheritanceType All
}
"MailUniversalDistributionGroup" {
@chrisbrownie
chrisbrownie / ParseDnsLog.ps1
Created February 19, 2016 02:26
Basics of parsing a Windows DNS Log file. Not good, but should be enough to jog the ol' memory.
$logFile = "dns2_cleaned.log"
$sr = New-Object System.IO.StreamReader($logFile)
$line = $sr.ReadLine()
$packets = @()
while ($line -ne $null) {
@chrisbrownie
chrisbrownie / RemoveEmptyLines.ps1
Created February 19, 2016 02:04
Removes empty lines from a file
$logFile = "$pwd\dns.log"
$newLogFile = "$pwd\dns_cleaned.log"
$sr = New-Object System.IO.StreamReader($logFile)
$sw = New-Object System.IO.StreamWriter($newLogFile)
$line = $sr.ReadLine()
while ($line -ne $null) {
if ($line.trim() -ne "") {
@chrisbrownie
chrisbrownie / FixOffice365Users.ps1
Created January 18, 2016 05:25
Sets ImmutableIDs for all Office 365 users based on AD...without needing to touch anything.
function Get-ImmutableId ($a) {
[System.Convert]::ToBase64String(([guid](Get-ADUser $a -Properties ObjectGuid).ObjectGuid).ToByteArray())
}
##
## WARNING: This script does not health check anything at all.
## If you run it without knowing what it does, you
## will probably break the internet, and not in the good way.
##
@chrisbrownie
chrisbrownie / Monitor-Website.ps1
Created December 11, 2015 00:47
Monitors a website's status
# Site to check
$site = "https://www.github.com"
# Seconds between checks
$interval = 2
while ($true) {
$result = try { Invoke-WebRequest $site -ErrorAction silentlycontinue } catch { $null }
if ($result.statuscode -eq 200) {
Write-Host "$site is up" -BackgroundColor green -ForegroundColor white
} else {