Skip to content

Instantly share code, notes, and snippets.

View adbertram's full-sized avatar

Adam Bertram adbertram

View GitHub Profile
## No
Do-Thing | Out-Null
## yes
$null = Do-Thing
[void](Do-Thing)
enum Color {
Red
Green
Blue
}
function Set-Color {
param (
[Color]$Color
)
enum Color {
Red
Green
Blue
}
function Set-Color {
param (
[Color]$Color
)
enum Color {
Red
Green
Blue
}
function Set-Color {
param (
[Color]$Color
)
@adbertram
adbertram / Select-Item.ps1
Last active March 15, 2024 12:28
An interactive PowerShell function to select items from a collection based on the first letter
function SelectItem {
<#
.SYNOPSIS
Selects an item from a provided list based on keyboard input.
.DESCRIPTION
The SelectItem function allows the user to select an item from a given list of strings by typing the first letter of the
item. The function iterates through the items that start with the given letter, allowing the user to press the same letter
repeatedly to cycle through the options. Selection is confirmed with the Enter key.
@adbertram
adbertram / timer.ps1
Created September 7, 2023 20:44
PowerShell Timer with Real-Time Counting
# Initialize timer variables
$timerStart = $null
$elapsedTime = $null
# Function to display elapsed time
function DisplayElapsedTime {
param (
[ref]$startTime,
[ref]$elapsedTime
)
#ifndef EMPLOYEE_SALARY_SLIP_H_INCLUDED
#define EMPLOYEE_SALARY_SLIP_H_INCLUDED
#include <iostream>
#include <string>
#include "Employee.h"
using namespace std;
class EmployeeSalarySlip : public Employee {
###################################################
# This is an associated snippet on learning Azure Functions by Jeff Brown at:
# https://adamtheatuomator.com/azure-functions-tutorial
###################################################
# The function URL appends the function name with a question mark and a code. This code is the function key and
# authenticates to the function for execution. Without this key, you would not be able to trigger the function.
# This key provides security so not just anyone can start the function.
$functionKey = '' ## Fill this in from the Get function URL page
$functionAppName = 'ata-powershell-functions'
###################################################
# This is an associated snippet on learning Azure Functions by Jeff Brown at:
# https://adamtheatuomator.com/azure-functions-tutorial
###################################################
## The using statement imports the System.Net namespace, and param() defines the function's parameters.
using namespace System.Net
## Input bindings are passed in via param block.
## The *$Request* parameter contains the information passed to the function during the HTTP request. This information includes the request headers, request body, HTTP method, parameters, and URL of the request.
function Set-RegistryValueForAllUsers {
<#
.SYNOPSIS
This function uses Active Setup to create a "seeder" key which creates or modifies a user-based registry value
for all users on a computer. If the key path doesn't exist to the value, it will automatically create the key and add the value.
.EXAMPLE
PS> Set-RegistryValueForAllUsers -RegistryInstance @{'Name' = 'Setting'; 'Type' = 'String'; 'Value' = 'someval'; 'Path' = 'SOFTWARE\Microsoft\Windows\Something'}
This example would modify the string registry value 'Type' in the path 'SOFTWARE\Microsoft\Windows\Something' to 'someval'
for every user registry hive.