Skip to content

Instantly share code, notes, and snippets.

View steviecoaster's full-sized avatar
🤠
It's a sweet day to write some Powershell

Stephen Valdinger steviecoaster

🤠
It's a sweet day to write some Powershell
View GitHub Profile
@steviecoaster
steviecoaster / Get-CurrentWeather.ps1
Last active September 25, 2017 14:17
Current Weather in PS Profile
Function Get-CurrentWeather {
#Save this function inside your Powershell Profile. Not sure what that is? Just type in $profile and hit enter in your PS Console!
#File doesn't exist? That's OK, use Powershell to create it!
#New-Item -File -Path $env:USERPROFILE\Documents\WindowsPowershell\ -Value $profile
#Give your script a voice!
Add-Type -assemblyname System.Speech
$speech = New-Object System.Speech.Synthesis.SpeechSynthesizer
@steviecoaster
steviecoaster / Invoke-SessionLog.ps1
Last active November 8, 2017 18:50
Automatically create a transcript of your Powershell Session. Keeps 7 days worth of history by default
<#
.SYNOPSIS
Automatically create transcript of your Powershell session.
.DESCRIPTION
Add this function to your Powershell Profile and call it with Invoke-SessionLog -Logpath \some\path to automatically keep
session history each time you open up powershell.
.EXAMPLE
Invoke-SessionLog -LogPath C:\PSLogs -DaysToKeep 7
@steviecoaster
steviecoaster / PCQuery.ps1
Last active June 1, 2018 20:24
Query for file
$Computers = Get-ADComputer -Filter * | Select Name
$file = /path/to/file
Foreach($c in $computers) {
#Uncomment to use UNC
If((Test-Path "\\$($c.Name)\C$\$file")){
#uncomment to use remoting
#If(Invoke-Command -Computer $c.Name -Command { (Test-Path $args[0])} -ArgumentList $file){
[pscustomobject]$cDetail = [ordered]@{
@steviecoaster
steviecoaster / New-RandomDataset.ps1
Last active July 17, 2018 15:11
Generate random datasets using the wonderful NameIT powershell module
Function New-RandomDataset {
<#
.SYNOPSIS
Generate random data for use in testing, demonstrations, etc.
.DESCRIPTION
Using the NameIT module, generate random data exported to a CSV file
.PARAMETER Count
The number of items in your dataset
.PARAMETER CSVPAth
@steviecoaster
steviecoaster / New-SocialInteraction.ps1
Created July 20, 2018 17:32
Explaining Conversations with my Wife in Powershell
Function New-SocialInteraction {
[cmdletBinding()]
Param(
[Parameter(Mandatory, Positon = 0)]
[String]$Person,
[Parameter(Mandatory, Position = 1)]
[String]$Topic
)
New-PSDrive -Name Brain -PSProvider FileSystem -Root Noggin
@steviecoaster
steviecoaster / New-LMGTFYLink.ps1
Last active July 25, 2018 02:34
Generates a LMGTFY link from a string, and copies to clipboard.
Function Find-Service {
<#
.SYNOPSIS
Find a specified service on remote endpoints
.PARAMETER Computername
The remote endpoint(s) to query
.PARAMETER ServiceDisplayName
The Display Name of the service to query
Function Test-VM {
[cmdletBinding()]
Param(
[Parameter]
[string]
$dummy
)
#Dynamic Params require [CmdletBinding()], but are defined on their own outside the main Param() block
DynamicParam {
$ParameterName = 'VM'
@steviecoaster
steviecoaster / Get-UserProfileSize.ps1
Last active September 26, 2018 01:19
User Folder Size
function Get-UserProfileSize {
<#
.SYNOPSIS
Gather profile sizes on a computer
.DESCRIPTION
Returns the size of a user profile on a given computername
.PARAMETER IncludeSpecial
Includes built-in accounts in the object
@steviecoaster
steviecoaster / Send-CatFact.ps1
Created October 9, 2018 21:41
Send a random cat fact to a computer
function Send-CatFactMessage {
<#
.SYNOPSIS
Send a cat fact to users on a computer.
.DESCRIPTION
Send a random cat fact to any number of computers and all users or a specific user. Supports credential passing.
.EXAMPLE
Send-CatFactMessage -PlayAudio
Sends cat fact message to all users on localhost and outputs fact through speakers.
.EXAMPLE