Skip to content

Instantly share code, notes, and snippets.

View chrisbrownie's full-sized avatar
🛩️
computering

Chris Brown chrisbrownie

🛩️
computering
View GitHub Profile
$host.UI.RawUI.WindowTitle = "$(($ENV:USERNAME).tolower())@localhost - $(Get-Location)"
# Check for Administrator elevation
$wid = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$prp = new-object System.Security.Principal.WindowsPrincipal($wid)
$adm = [System.Security.Principal.WindowsBuiltInRole]::Administrator
$IsAdmin = $prp.IsInRole($adm)
if ($IsAdmin) {
$Host.UI.RawUI.BackgroundColor = "DarkRed"
Clear-Host
Write-Host "`n`tWarning: PowerShell is running as an Administrator.`n"
function cl {
Param(
$Location
)
try {
Set-Location $Location -ErrorAction Stop
Get-ChildItem
} catch {
throw $_
Set-PSReadlineKeyHandler -Key ctrl+d -Function DeleteCharOrExit
Remove-Item Alias:wget
Remove-Item Alias:curl
@chrisbrownie
chrisbrownie / HelloAgain.ps1
Last active January 18, 2018 22:34
Demo script that generates an output
New-Object -TypeName PSObject -Property @{Message="Hello, again!"}
@chrisbrownie
chrisbrownie / Invoke-Gist.ps1
Last active February 26, 2018 23:05
Invoke-Gist is a PowerShell function that allows you to invoke a gist by ID or URL.
function Invoke-Gist {
Param(
[String]
$Identity,
[String]
$Arguments
)
$gistBase = "https://api.github.com/gists/"
@chrisbrownie
chrisbrownie / CopyFilesToOffice365Group.ps1
Last active February 19, 2018 23:36
Copies files from the local computer to an Office 365 Group
param(
[String]
$Path, #the path to the files to be uploaded
[String]
$siteUrl, #this is the URL of the Group in the format https://contoso.sharepoint.com/sites/yourGroupName
[String]
$listName = "Shared Documents"
#this is the path within the site to the place where you want to put the files
@chrisbrownie
chrisbrownie / DownloadOlympusPhotos.ps1
Last active February 4, 2018 09:46
Downloads photos from an Olympus camera
$CameraIp = "192.168.0.10"
$DateFrom = Get-Date "29 December 2017"
function Invoke-OLApiCommand {
Param(
[String]$Command,
[String]$Arguments
)
$CommandVerb = $Command.Split("_")[0]
@chrisbrownie
chrisbrownie / Get-HappyHourDeals.ps1
Created March 7, 2018 05:38
Gets the current Virgin Australia happy hour deals. It's not great but it bloody works and that's all that matters
$HHUrl = "http://happyhour.virginaustralia.com/sale-on"
$page = Invoke-WebRequest -Uri $HHUrl
$flightDivs = $page.ParsedHtml.body.getElementsByClassName('card-flight')
foreach ($flightDiv in $flightDivs) {
New-Object -TypeName PSObject -Property @{
"From" = $flightDiv.getElementsByTagName("h3")[0].innerText.Split("`n")[0].Trim() -replace '\ to', ''