Skip to content

Instantly share code, notes, and snippets.

@SMSAgentSoftware
SMSAgentSoftware / New-InteractiveDataDisplayChart.ps1
Created June 20, 2018 16:43
Creates a simple interactive bar chart using Microsoft's opensource Interactive Data Display project
## Example of how to use the opensource InteractveDataDisplay module from Microsoft to create a WPF chart in PowerShell
Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName System.IO.Compression.FileSystem
# Location to download the required libraries and reference them from
$Source = "C:\Users\tjones\OneDrive\PowerShell\POSH Projects\Interactive Data Display"
#region DownloadDependencies
$URLs = @(
@indented-automation
indented-automation / Get-FileEncoding.ps1
Last active November 1, 2022 19:56
Signature-based encoding detection
using namespace System.Collections.Generic; using namespace System.Linq
function Get-FileEncoding {
<#
.SYNOPSIS
Attempt to determine a file type based on a BOM or file header.
.DESCRIPTION
This script attempts to determine file types based on a byte sequence at the beginning of the file.
If an identifiable byte sequence is not present the file type cannot be determined using this method.
@Jaykul
Jaykul / Start-Demo.ps1
Last active December 2, 2022 08:55
Doing demos with just PSReadLine
function Start-Demo {
[CmdletBinding()]
param(
# A history file with a command on each line (or using ` as a line-continuation character)
[Parameter(Mandatory)]
[Alias("PSPath")]
[string]$Path
)
[Microsoft.PowerShell.PSConsoleReadLine]::ClearHistory()
<#
.SYNOPSIS
Uses XML transformation on a specified XML file
.DESCRIPTION
Performs XML configuration changes to a given XML file via XML-Document-Transform (XDT) commands specified within a seperate XML file.
.EXAMPLE
PS C:\> Use-XMLTransform -XML 'D:\myApp\app.config' -XDT 'D:\myApp\app.release.config'
Transforms configuration within app.config using the XDT commands found in app.release.config
.INPUTS
String literal paths to XML/XDT docs and optionally XmlTransform.dll
@jamesfreeman959
jamesfreeman959 / keepawake.ps1
Last active May 7, 2024 14:52
A very simple PowerShell script to keep a Windows PC awake and make lync think the user is active on the keyboard
# Useful references:
#
# https://superuser.com/questions/992511/emulate-a-keyboard-button-via-the-command-line
# https://ss64.com/vb/sendkeys.html
# https://social.technet.microsoft.com/Forums/windowsserver/en-US/96b339e2-e9da-4802-a66d-be619aeb21ac/execute-function-one-time-in-every-10-mins-in-windows-powershell?forum=winserverpowershell
# https://learn-powershell.net/2013/02/08/powershell-and-events-object-events/
#
# Future enhancements - use events rather than an infinite loop
$wsh = New-Object -ComObject WScript.Shell
while (1) {
@widdowquinn
widdowquinn / github_pages_jekyll_minimal_mistakes.md
Created December 19, 2017 17:56
Create a Jekyll blog on GitHub Pages, using the Minimal-Mistakes Theme

Creating a Jekyll blog on GitHub Pages with Minimal-Mistakes

Setup

First, create a new Jekyll site and corresponding GitHub Pages repository, then test it locally at http://localhost:4000:

$ gem install jekyll bundler
$ jekyll new <REPO>/
Running bundle install in /Users/<USER>/Development/GitHub/<REPO>... 
@Jaykul
Jaykul / Get-DependencyTree.ps1
Last active September 1, 2022 14:38
Print a module dependency tree for modules
filter Get-DependencyTree {
<#
.NOTES
From https://gist.github.com/Jaykul/304e7874d629ef4848c9acd0cfd550d0
#>
param(
[Parameter(Mandatory, ValueFromPipeline)]
[System.Management.Automation.PSModuleInfo[]]$Module,
$Depth = 0,
@SMSAgentSoftware
SMSAgentSoftware / New-WPFClock
Created September 15, 2017 13:53
A clock widget for PowerShell using the free Arction Gauge control
Function New-WPFClock {
## Generates a clock displaying the current system time
## Requires the Arction WPF Gauges, a free download from https://www.arction.com/free-gauges/
## Set the location of the Arction Gauges dll on line 26
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$false,Position=0)]
@latkin
latkin / regexinfo.ps1
Last active April 1, 2022 01:43
Regex matching helper
<#
Dumps capture group locations and names/numbers
Example:
> regexinfo 'Jenny: 555-867-5309' '(?<name>\w+):\s+(?<phone>(?:(?<area>\d{3})-)?(\d{3}-\d{4}))'
[Jenny]: [[555]-[867-5309]]
| || |
| || 1
| |area
| phone
@klinkby
klinkby / Get-Spreadsheet.ps1
Last active June 3, 2019 17:35
Powershell script to read Excel spreadsheet contents
function Get-Spreadsheet {
param(
[Parameter(Mandatory = $true)]
[ValidateScript({ Test-Path $_ -PathType Leaf })]
[string]$Path
)
try {
[DocumentFormat.OpenXml.Packaging.SpreadsheetDocument] | Out-Null
}
catch {