Skip to content

Instantly share code, notes, and snippets.

@Ryan2065
Ryan2065 / MountDrive.ps1
Created December 22, 2015 17:14
Mount ephing drive
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]
@Ryan2065
Ryan2065 / New-EphingWPFCode.ps1
Last active January 18, 2016 21:22
Create WPF code from XAML
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
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 / WinPENanoDomainJoin.ps1
Created October 15, 2016 13:54
Nano domain join for use in SCCM task sequence!
$source = @'
using System;
using System.Security.Principal;
using System.Runtime.InteropServices;
namespace ECGCAT
{
public class Kernel32
{
[DllImport("Kernel32.dll", SetLastError = true)]
@Ryan2065
Ryan2065 / JobTracker.ps1
Last active August 10, 2020 21:47
Job Tracker using EFPosh PowerShell Module
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
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)