Display Profile Functions
If you are like me and have multiple machines you work on with different profiles, it can be difficult to remember which profile contains which functions. So, I wrote a quick function that will display all the functions for me on start up. Just add the code below to the bottom of your $profile file. Function Get-ProfileFunctions { $__ProfileFunctions =...
A Quick Lesson in Boolean
I often see scripts that are checking for True/False values using an If/Else statement like the one below. While this technically will work for Boolean values, there are situations where this will not work. For example, if you pass the string value of “False” to the statement above it will evaluate as True. This is because the if condition in...
Remove First Entry in Fixed Array
Here is a quick little trick for removing the first entry in a fixed size array. This can be used when you receive the error message: Exception calling “RemoveAt” with “1” argument(s): “Collection was of a fixed size.” # Remove first entry $array = $array[1..($array.Length-1)]
Homework – Double Digit Addition without Carrying
My son decided to pretend to be sick from school the other day, so after we finished all the work the teach gave us, I decided to make him some extra work. This code will generate a page with 25 double digit addition problems. They haven’t learn to carry over digits yet, so all sums are less than 10. Maybe...
Quick and Easy Day of the Week Date Picker
$today = [datetime]::Today $dates = @() for($i = $today.AddDays(0).DayOfWeek.value__; $i -ge 0; $i--){ $dates += $today.AddDays(-$i) } $date = $dates | Out-GridView -PassThru
Out-GridView for VS Code
Out-GridView is a great tool for quickly creating selection dialogs or displaying information that you sort. However, when using it in Visual Studio Code (VS Code), it tends to display the grid window behind the VS Code window. So, in an effort to prevent me from having to click my mouse one more time, I created the function Out-GridViewCode. This...
Copy Your Profile from ISE to Visual Studio Code
# Get the path to the Profile files $ISEProfile = Join-Path (Split-Path $profile) "Microsoft.PowerShellISE_profile.ps1" $VSCProfile = Join-Path (Split-Path $profile) "Microsoft.VSCode_profile.ps1" # If the ISE Profile exists write the content to the VSCode Profile if(Test-Path $ISEProfile){ # Check if profile exists, create if it does not if(!(Test-Path $VSCProfile)){ New-Item $VSCProfile -ItemType file -Force } # write content to VSCode Profile "`n#...
Convert From WMI Datetime
[Management.ManagementDateTimeConverter]::ToDateTime($WMIDate)
PowerShell Timer with Alarm
Function Start-Timer { param( [Parameter(Mandatory=$true)] [int]$seconds, [Parameter(Mandatory=$false)] [switch]$alarm ) $a = $(Get-Date) For($i=1;$i -le $seconds;$i++){ Write-Progress -Activity "$seconds Second Timer" -Status $i -PercentComplete $(($i/$seconds)*100) -id 1 Start-Sleep -Seconds 1 } if($alarm){ For($i=1;$i -le 10;$i++){ [console]::beep(500,300) } } }
Make Your Computer Talk
Add-Type -AssemblyName System.Speech $Speech = New-Object System.Speech.Synthesis.SpeechSynthesizer $Speech.Speak("I'm sorry Dave, I'm afraid I can't do that")