Skip to content

Instantly share code, notes, and snippets.

@amandadebler
amandadebler / AKSDockerVersionReporter.ps1
Created February 13, 2019 08:31
Reports the Docker runtime version for all nodes in all AKS clusters in all subscriptions in an Azure tenant
$mySubscriptions = $(az account list --query [].id -o tsv)
foreach ($subscription in $mySubscriptions) {
$clusters = $(az aks list --subscription $subscription) | ConvertFrom-Json
foreach ($cluster in $clusters) {
"$($cluster.name) in resource group $($cluster.resourceGroup) in subscription $subscription"
az aks get-credentials --resource-group $($cluster.resourceGroup) --name $($cluster.name) --subscription $subscription --overwrite-existing
kubectl get nodes -o custom-columns=NAME:.metadata.name,VERSION:.status.nodeInfo.containerRuntimeVersion
}
}
@amandadebler
amandadebler / PowerShell Prompt.ps1
Last active March 12, 2019 22:28 — forked from fatherjack/PowerShell Prompt.ps1
Two-line prompt with last command execution time and tail of present working directory - modification of FatherJack's prompt, which was inspired by FriedrichWeinmann
function Prompt {
try {
$history = Get-History -ErrorAction Ignore -Count 1
if ($history) {
$ts = New-TimeSpan $history.StartExecutionTime $history.EndExecutionTime
Write-Host "[" -NoNewline
switch ($ts) {
{$_.TotalSeconds -lt 1} {
[decimal]$d = $_.TotalMilliseconds
@amandadebler
amandadebler / Get-SP500Summary.ps1
Last active August 26, 2019 10:19
S&P 500 weights and latest closing prices
$response = invoke-webrequest "https://www.slickcharts.com/sp500"
$table = $response.parsedhtml.body.childnodes[6].childnodes[1].childnodes[0].childnodes[0].childnodes[1].childnodes[0]
# Column Headers
$columns = foreach ($node in $table.childnodes[0].childnodes[0].childnodes) {$node.innertext}
$stockrows = $table.childnodes[1].childnodes
$stocks = foreach ($row in $stockrows) {
$attributes = @{}
for ($i=0; $i -lt $($columns.count); $i++) {
$attributes.Add($columns[$i],$row.childnodes[$i].innertext.trim())
function Get-SharesInAmount {
[CmdletBinding()]
param (
$stock,
$amount,
$transactionCost = 5,
$maxCostRatio = 0.02
)
begin {
@amandadebler
amandadebler / Get-Portfolio
Created August 26, 2019 15:03
The robo-advisor in PowerShell that no one asked for
function Get-Portfolio {
[CmdletBinding()]
param (
$amount,
$transactionCost = 5,
$maxCostRatio = 0.02
)
begin {
@amandadebler
amandadebler / BootlegPowerShellGet.psm1
Last active October 16, 2019 18:34 — forked from Jaykul/PowerShellGet.psm1
PowerShell Gallery Module - Bootleg Edition
<#
Forked from https://github.com/jaykul Gist, posted in response to my Twitter
whinge about PowerShellGet in the enterprise - Thank you, Joel Bennett!
This adds the ability to use a web proxy, using your current session's
credentials. Might add option to use other credentials, if there's demand.
It also adds a 'BL' (Bootleg) prefix to the nouns, just to prevent confusion with the "real"
cmdlets. Feel free to remove them.
<#
Get-CsTopologyFixed.ps1 v1.0
Last updated 2015-02-27 by Amanda Debler, https://mandie.net
Please let me know about any improvements you've made or mistakes you've found!
#>
@amandadebler
amandadebler / Base64.ps1
Created May 29, 2020 12:51
Convert to and from Base64, since there's no built-in Windows command for this
function ConvertTo-Base64 {
Param(
$Text
)
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($Text)
[System.Convert]::ToBase64String($Bytes)
}
function ConvertFrom-Base64 {
Param(