Skip to content

Instantly share code, notes, and snippets.

@ChendrayanV
ChendrayanV / server.ps1
Created November 17, 2018 03:12
Simple Login Page Demo Using PSHTML and Polaris (PowerShell Modules)
Import-Module Polaris -Verbose
Import-Module PSHTML -Verbose
Add-Type -AssemblyName System.Web
New-PolarisGetRoute -Path "/Login" -Scriptblock {
$HTML = html {
head {
Title "Login Page"
}
#################################################
# Terraform vs. Pulumi vs. Crossplane #
# Infrastructure as Code (IaC) Tools Comparison #
# https://youtu.be/RaoKcJGchKM    #
#################################################
#########
# Setup #
#########
@Staggerlee011
Staggerlee011 / pre-commit PowerShell git Hook
Created January 1, 2018 21:54
Example of a pre-commit hook using powershell used in Blog post:
write-output "This is a pre-commit powershell call"
write-output "======================================="
Import-Module -Name PSScriptAnalyzer
$changes = git diff --name-only
$output = @()
foreach ($change in $changes)
{
@Fabaderheld
Fabaderheld / Set-AzAPIPermission.ps1
Last active July 7, 2022 18:32
Permissions Ids for Graph
Get Permissions
# MS Graph Permissions
(Get-AzAdServicePrincipal -ApplicationId 00000003-0000-0000-c000-000000000000).AppRole | Select *
(Get-AzAdServicePrincipal -ApplicationId 00000003-0000-0000-c000-000000000000).Oauth2PermissionScope | Select *
# Azure AD Graph
(Get-AzAdServicePrincipal -ApplicationId 00000002-0000-0000-c000-000000000000).AppRole | Select *
(Get-AzAdServicePrincipal -ApplicationId 00000002-0000-0000-c000-000000000000).Oauth2PermissionScope | Select *
@brettmillerb
brettmillerb / zshrc-theme
Last active August 25, 2022 06:09
.zshrc | macOs
# Path to your oh-my-zsh installation.
export ZSH="/Users/brett.miller/.oh-my-zsh"
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
# Set name of the theme to load
ZSH_THEME="powerlevel9k/powerlevel9k"
DISABLE_AUTO_TITLE="true"
# Plugins
@JustinGrote
JustinGrote / Get-ParamBlock.ps1
Created July 7, 2022 05:20
Get a hashtable of the parameters in your param block, useful for splatting.
using namespace system.collections.generic
function Get-ParamBlock ([String[]]$Name) {
[hashset[string]]$params = $PSCmdlet.MyInvocation.MyCommand.Parameters.Keys
$params.ExceptWith([string[]]([PSCmdlet]::CommonParameters + [PSCmdlet]::OptionalCommonParameters))
$result = @{}
if ($Name) {$params = $params -in $Name}
foreach ($name in $params) {
$result.$name = $PSCmdlet.GetVariableValue($name)
}
return $result
@JustinGrote
JustinGrote / Receive-Task.ps1
Last active September 21, 2022 21:05
"Await" one or more tasks in PowerShell in a cancellable manner (e.g. ctrl-c still works)
using namespace System.Threading.Tasks
using namespace System.Collections.Generic
filter Receive-Task {
#Wait on one or more tasks in a cancellable manner
[CmdletBinding()]
param(
[parameter(Mandatory, ValueFromPipeline)][Task]$Task,
#How long to wait before checking for a cancellation in milliseconds
[int]$WaitInterval = 500
)
@BelRarr
BelRarr / list-expiring-app-registrations.ps1
Created January 10, 2022 14:27
Get the list of expired or soon-to-expire azure app registrations
$daysToExpire = 30
$SoonToBeExpiredList = @()
$AlreadyExpiredList = @()
# Connect to AzureAD
Write-Output "Connecting to AzureAD..."
$connection = Get-AutomationConnection -Name AzureRunAsConnection
Connect-AzureAD -TenantId $connection.TenantID -ApplicationId $connection.ApplicationID -CertificateThumbprint $connection.CertificateThumbprint
@potatoqualitee
potatoqualitee / profile.ps1
Last active November 4, 2022 19:37
prompt
function Prompt
{
Write-Host "[" -NoNewline
Write-Host (Get-Date -Format "HH:mm:ss") -ForegroundColor Gray -NoNewline
try
{
$history = Get-History -ErrorAction Ignore
if ($history)
{
@dfinke
dfinke / CFSBuddy.ps1
Created September 17, 2014 14:37
PowerShell v5.0 ConvertFrom-String Buddy - A GUI that helps you work with this new powerful cmdlet
#Requires -Version 5.0.9814.0
if(!($PSVersionTable.PSVersion.Major -ge 5 -and $PSVersionTable.PSVersion.Build -ge 9814)) {
"Sorry you need PSVersion 5.0.9814.0 or newer"
$psversiontable
return
}
Add-Type -AssemblyName presentationframework