Skip to content

Instantly share code, notes, and snippets.

@IISResetMe
IISResetMe / Get-ADUserPasswordExpiration.ps1
Last active July 10, 2017 20:39
Password expiration function that takes fine-grained password policies into account
#Requires -Modules ActiveDirectory
function Get-ADUserPasswordExpiration
{
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[Alias('DistinguishedName')]
[Microsoft.ActiveDirectory.Management.ADUser[]]$Identity
)
@IISResetMe
IISResetMe / bad.ps1
Last active September 25, 2017 23:32
Middle Management Reporting in PowerShell
$Properties = 'employeeID'
# Retrieve all workers with their "manager" attribute
Get-ADUser -Filter "title -like '*worker*'" -Properties @('manager';$Properties) |ForEach-Object {
# Iterate over workers, retrieve each workers manager individually
[pscustomobject]@{
Worker = $_
Manager = Get-ADUser -Identity $_.manager -Properties $Properties -ErrorAction SilentlyContinue
}
}
@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)
{
@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)
{
@markekraus
markekraus / ConvertKMSEncryptedStrings.ps1
Created February 18, 2018 19:41
PowerShell Functions to convert a string to a base64 representation of the KMS encryoted string and to convert back to an unencrypted string
function ConvertTo-Base64KMSEncryptedString {
[CmdletBinding()]
param (
[Parameter(
Mandatory = $true,
ValueFromPipeline = $true
)]
[String[]]
$String,
@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"
}
@JustinGrote
JustinGrote / ModuleFast.ps1
Last active July 24, 2023 16:26
Bootstrap Script for a High Performance Module Installer
using namespace System.Net.Http
#requires -version 7.2
# This is the bootstrap script for Modules
[CmdletBinding(PositionalBinding = $false)]
param (
#Specify a specific release to use, otherwise 'latest' is used
[string]$Release = 'latest',
#Specify the user
[string]$User = 'JustinGrote',
#Specify the repo
@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
@rchaganti
rchaganti / downloadTerraform.ps1
Created October 13, 2020 09:18
Download and Install Terraform - Windows (PowerShell)
[CmdletBinding(DefaultParameterSetName='Version')]
param
(
[Parameter(ParameterSetName='Latest', Mandatory = $true)]
[Parameter(ParameterSetName='Version', Mandatory = $true)]
[String]
$SaveToPath,
[Parameter(ParameterSetName='Version', Mandatory = $true)]
[String]
@JustinGrote
JustinGrote / Get-AzRetailPrice.ps1
Created November 2, 2020 01:45
Azure Retail Pricing API Proof of Concept
function Get-AzSpotPrice {
[CmdletBinding()]
param (
#VM SKU (e.g. Standard_F8s)
[String]$Sku,
#Azure Region (e.g. brazilsouth)
[String]$Region,
#ODATA filter to use on the data
[String]$Filter,
#Maximum number of records to retrieve, or specify 'Unlimited' for all records. Defaults to 100. This behaves like the Exchange Cmdlets