Skip to content

Instantly share code, notes, and snippets.

View PowerShellPrompt.ps1
function Prompt
{
#Based off https://dbatools.io/prompt/ - but doesn't show the current time.
try
{
$history = Get-History -ErrorAction Ignore
if ($history)
{
Write-Host "[" -NoNewline
if (([System.Management.Automation.PSTypeName]'Sqlcollaborative.Dbatools.Utility.DbaTimeSpanPretty').Type)
@Ryan2065
Ryan2065 / JobTracker.ps1
Last active Aug 10, 2020
Job Tracker using EFPosh PowerShell Module
View JobTracker.ps1
Function Start-CollectionMigration {
Param($Collection)
Start-Sleep -Milliseconds 250
}
Function Test-CollectionMigration {
Param($Collection)
$Random = Get-Random -Minimum 1 -Maximum 10
if($Random -eq 2){
return $false
@Ryan2065
Ryan2065 / WinPENanoDomainJoin.ps1
Created Oct 15, 2016
Nano domain join for use in SCCM task sequence!
View WinPENanoDomainJoin.ps1
$source = @'
using System;
using System.Security.Principal;
using System.Runtime.InteropServices;
namespace ECGCAT
{
public class Kernel32
{
[DllImport("Kernel32.dll", SetLastError = true)]
View Find Chess counts
Function Start-EphingThreads {
Param($ScriptBlock, $threads)
$SyncTable.ThreadsInProg = New-Object System.Collections.ArrayList
$Synctable.Runspaces = @{}
$SessionState = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault()
$SessionState.ApartmentState = "STA"
$SessionState.Variables.Add((New-Object -TypeName System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'SyncTable', $SyncTable, ""))
$SyncTable.RunspacePool = [RunspaceFactory]::CreateRunspacePool(1, $Threads, $SessionState, $Host)
$SyncTable.RunspacePool.Open()
for ($i = 0; $i -lt $Threads; $i++) {
@Ryan2065
Ryan2065 / New-EphingWPFCode.ps1
Last active Jan 18, 2016
Create WPF code from XAML
View New-EphingWPFCode.ps1
Function New-EphingWPFCode {
<#
.SYNOPSIS
Writes the code for a new WPF window in the ISE
.DESCRIPTION
The $xaml varialbe needs to be loaded in the session before this is run
Make sure to highlight the $xaml varialbe and run it!
.EXAMPLE
@Ryan2065
Ryan2065 / MountDrive.ps1
Created Dec 22, 2015
Mount ephing drive
View MountDrive.ps1
Function Mount-EphingDrive {
Param ($Path)
$DriveLetter=""
$MountedDrive = Mount-VHD -Path $Path -ErrorAction SilentlyContinue -PassThru
$Drives = (Get-Partition -DiskNumber $MountedDrive.DiskNumber).DriveLetter
If ($Drives.Count -gt 1) {
$LargestDrive = 0
For ($d = 0; $d -lt $Drives.Count; $d++) {
If (($Drives[$d] -ne [char]0) -and ((Get-Partition -DriveLetter $Drives[$d]).Size -gt $LargestDrive)) {
$DriveLetter = $Drives[$d]
You can’t perform that action at this time.