Skip to content

Instantly share code, notes, and snippets.

@davewilson
davewilson / Play-Mario.ps1
Last active March 17, 2024 15:35
Super Mario Theme in PowerShell
Function Play-Mario {
[System.Console]::Beep(659, 125);
[System.Console]::Beep(659, 125);
[System.Threading.Thread]::Sleep(125);
[System.Console]::Beep(659, 125);
[System.Threading.Thread]::Sleep(167);
[System.Console]::Beep(523, 125);
[System.Console]::Beep(659, 125);
[System.Threading.Thread]::Sleep(125);
[System.Console]::Beep(784, 125);
@davewilson
davewilson / Play-SweetChildOMine.ps1
Created May 20, 2013 14:51
The opening to Sweet Child O' Mine in PowerShell
Function Play-SweetChildOMine {
#First Stanza
[System.Console]::Beep(587.3,200)
[System.Console]::Beep(1174.7,200)
[System.Console]::Beep(880,200)
[System.Console]::Beep(784,200)
[System.Console]::Beep(1568,200)
[System.Console]::Beep(880,200)
[System.Console]::Beep(1480,200)
[System.Console]::Beep(880,200)
Function Get-EventLogAudit {
param (
$whichLog,
[datetime]$start,
[datetime]$end
)
$totalDays = ($end - $start).Days
$randomDay = $start.AddDays((Get-Random $totalDays))
$randomDayHour = $randomDay.AddHours((Get-Random 24))
@davewilson
davewilson / CommonShare.ps1
Last active February 10, 2017 23:48
Mounts and Dismounts commonly used network shares
<#
.Synopsis
Maps commonly used network shares
.DESCRIPTION
Maps drives for commonly used network shares. Username parameter will map the drives as a specific user
.EXAMPLE
Mount-CommonShare
.EXAMPLE
Mount-CommonShare -Username stcxyz
#>
<#
.Synopsis
Expands a shortened URL to its full URL
.DESCRIPTION
Expands a shortened URL to its full URL
.EXAMPLE
Get-FullURL http:/bit.ly/12345
#>
function Get-FullURL
{
@davewilson
davewilson / emailloggedinusers.ps1
Created July 10, 2014 20:24
Email list of logged in users
#get usernames and email
#from http://www.reddit.com/r/PowerShell/comments/2acnqh/computerlist_filter_by_user/
$MachineList = Get-Content -Path H:\ListOfMachines.txt; # One system name per line
foreach ($machine in $MachineList){
$params = @{'ComputerName'=$machine;
'Namespace'='root\cimv2';
'Class'='Win32_ComputerSystem';
'ErrorAction'='SilentlyContinue'
}
$user = (Get-WmiObject @params).UserName
@davewilson
davewilson / gist:a66f2b084ffbaae5bc80
Created August 19, 2014 19:41
Install .NET 3.5 on Windows 8.1
Fix error code 0x800F0906 when trying to install .NET 3.5 on Windows 8.1
dism /online /enable-feature /featurename:NetFx3 /all /source:d:\sources\sxs /limitaccess
@davewilson
davewilson / pathmanip.ps1
Last active August 29, 2015 14:06
Useful Path Manipulation Shortcuts
#http://powershell.com/cs/blogs/tips/archive/2014/09/08/useful-path-manipulation-shortcuts.aspx
[System.IO.Path]::GetFileNameWithoutExtension('file.ps1')
[System.IO.Path]::GetExtension('file.ps1')
[System.IO.Path]::ChangeExtension('file.ps1', '.copy.ps1')
[System.IO.Path]::GetFileNameWithoutExtension('c:\test\file.ps1')
[System.IO.Path]::GetExtension('c:\test\file.ps1')
[System.IO.Path]::ChangeExtension('c:\test\file.ps1', '.bak')
@davewilson
davewilson / Kaizen.ps1
Last active August 29, 2015 14:17
PowerShell Kaizen
# Source: http://jdhitsolutions.com/blog/essential-powershell-resources/
Get-Command -Module Microsoft*,Cim*,PS*,ISE | Get-Random | Get-Help -ShowWindow
Get-Random -input (Get-Help about*) | Get-Help -ShowWindow
$outputfilepath = "C:\Located-PST.csv"
$searchpath = "SEARTH_PATH"
Get-ChildItem -Force $searchpath -include *.pst -Recurse | Where-Object { ($_.PSIsContainer -eq $false) } | Select-Object Name,Directory,Length | Export-Csv $outputfilepath -NoTypeInformation