Skip to content

Instantly share code, notes, and snippets.

View chrisbrownie's full-sized avatar
🛩️
computering

Chris Brown chrisbrownie

🛩️
computering
View GitHub Profile
Remove-Item Alias:wget
Remove-Item Alias:curl
Set-PSReadlineKeyHandler -Key ctrl+d -Function DeleteCharOrExit
function cl {
Param(
$Location
)
try {
Set-Location $Location -ErrorAction Stop
Get-ChildItem
} catch {
throw $_
# 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"
$host.UI.RawUI.WindowTitle = "$(($ENV:USERNAME).tolower())@localhost - $(Get-Location)"
$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', ''
@chrisbrownie
chrisbrownie / Connect-ExopsSession.ps1
Last active December 11, 2017 22:35
Automatically discovers newest EXOPS module in the user's profile
function UpdateImplicitRemotingHandler {
$modules = Get-Module tmp_*
foreach ($module in $modules)
{
[bool]$moduleProcessed = $false
[string] $moduleUrl = $module.Description
[int] $queryStringIndex = $moduleUrl.IndexOf("?")
@chrisbrownie
chrisbrownie / Get-MsolServicePlans.ps1
Last active December 7, 2017 02:28
Returns a list of each sku and the service plans associated. For creating LicenseOption objects with New-MsolLicenseOptions
foreach ($sku in (Get-MsolAccountSku) ) {
foreach ($sp in $sku.ServiceStatus) {
New-Object -TypeName PSObject -Property @{"AccountSkuId"=$sku.AccountSkuId;"ServicePlan"=$sp.ServicePlan.ServiceName}
}
}
@chrisbrownie
chrisbrownie / GetExchangeGroupMemberships.ps1
Created November 29, 2017 00:59
Returns the membership of all Exchange Online Distribution Groups
$allDistributionGroups = Get-DistributionGroup -ResultSize unlimited
$allGroupMemberships = $allDistributionGroups | ForEach-Object {
$thisGroup = $_
Get-DistributionGroupMember -Identity $thisGroup.Identity |
Select-Object `
@{Name="GroupIdentity";Expression={$thisGroup.primarySmtpAddress}},
@{Name="MemberAddress";Expression={$_.PrimarySmtpAddress}}
}
@chrisbrownie
chrisbrownie / GenerateDocFxToc.ps1
Created November 5, 2017 22:05
DocFx TOC generator
$articleRoot = "articles"
$tocFileTypes = @("md")
function CreateTocForFolder {
Param(
[String]$Path
)
# First, create a toc for child folders