Skip to content

Instantly share code, notes, and snippets.

View bmkaiser's full-sized avatar

Brian Kaiser bmkaiser

View GitHub Profile
@bmkaiser
bmkaiser / Update-PowerShell.ps1
Last active October 5, 2020 13:07
Wrapper function to update PowerShell Stable and Preview channels
#Requires -Version 7.0
function Update-PowerShell {
[Alias('ups')]
param (
# THE POWERSHELL CHANNEL THAT YOU WANT TO INSTALL
[Parameter(Mandatory = $true)]
[ValidateSet(
'Stable',
'Preview'
ErrorMessage="Value '{0}' is invalid. Please use one of: '{1}'"
@bmkaiser
bmkaiser / Get-RecycleBin.ps1
Last active December 23, 2021 19:42
Gets Items from the Windows Recycle Bin and Optionally Deletes Them
#Requires -Version 3.0
#Requires -PSEdition Desktop
function Get-RecycleBin {
<#
.SYNOPSIS
Lists and deletes items from the Windows Recycle Bin.
.DESCRIPTION
Lists and optionally deletes items in the Windows Recycle Bin for a specific user.
@bmkaiser
bmkaiser / Manage-HPBIOSSettings.ps1
Last active January 29, 2024 03:47
How to Query and Assign HP BIOS Settings Using WMI
param (
[Parameter(Mandatory=$true)]
[string[]]
$ComputerName
)
#region GET BIOS SETTINGS
$filter = @(
"Name like '%day'"
"Name like 'BIOS Power-On%'"
@bmkaiser
bmkaiser / Decrypt-SecurePasswords.ps1
Last active June 5, 2020 17:44
How to Decrypt Password Files that Have Been Encrypted with a Key
$keyPath = 'path.key'
$passPath = 'path.txt'
$account = 'username'
$key = Get-Content -Path $keyPath
$pass = Get-Content -Path $passPath | ConvertTo-SecureString -Key $key
# POWERSHELL 5.1, 6
$credentials = New-Object -TypeName System.Management.Automation.PSCredential($account,$pass)
$clearPass = $credentials.GetNetworkCredential().Password
@bmkaiser
bmkaiser / New-ConnectToExchangeOnline.ps1
Last active May 21, 2020 23:37
Fewer Keystrokes to Connect to Exchange Online with PowerShell
$env:UPN = (whoami /upn)
$PSDefaultParameterValues = @{
'Connect-ExchangeOnline:UserPrincipalName' = "$env:UPN"
}
Set-Alias -Name cexo -Value Connect-ExchangeOnline