This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using NAudio.Wave; | |
using NAudio.Wave.SampleProviders; | |
namespace FireAndForgetAudioSample | |
{ | |
class AudioPlaybackEngine : IDisposable | |
{ | |
private readonly IWavePlayer outputDevice; | |
private readonly MixingSampleProvider mixer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Expand-AstVariables { | |
param ( | |
[Parameter(Mandatory, ValueFromPipeline)] | |
[System.Management.Automation.Language.Ast] $Statement, | |
[Parameter(Mandatory)] | |
[ref] $result, | |
[Parameter(Mandatory)] | |
[PSObject] $Properties | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-Hyperlink { | |
<# | |
.SYNOPSIS | |
Creates a VT Hyperlink in a supported terminal such as Windows Terminal 1.4+ | |
.NOTES | |
There's a more powerful version of this, with color support and more, in PANSIES | |
.EXAMPLE | |
New-Hyperlink https://github.com/Jaykul/PANSIES PANSIES | |
Creates a hyperlink with the text PANSIES which links to the github project |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace System.Management.Automation | |
using namespace System.Collections.Generic | |
class ArgumentCompleterBase : IArgumentCompleter { | |
hidden [List[CompletionResult]] $Results = [List[CompletionResult]]::new() | |
[string] $WordToComplete | |
[Language.CommandAst] $commandAst | |
# override in child class | |
[void] AddCompletionsFor([string] $commandName, [string] $parameterName, [Collections.IDictionary] $fakeBoundParameters) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-Data { | |
Param ( | |
[Parameter()][int]$MajorVersion = $(([environment]::OSVersion.Version).Major), | |
[Parameter()][int]$MinorVersion = $(([environment]::OSVersion.Version).Minor), | |
[Parameter()][string]$Find = "wcPatchUri" | |
) | |
Process{ | |
Try{ | |
$cdnBaseURI = "https://example.com" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-SelfCleaningJob { | |
param( | |
$Name=$([Guid]::NewGuid().Guid) | |
) | |
$job = Start-Job -Name $Name { 1..10 | % { Write-Output $_ } } | |
$jobCleanup = Register-ObjectEvent $job -EventName StateChanged -Action { | |
if($EventArgs.JobStateInfo.State -eq "Completed") { | |
# Note this prints to host no matter what's going on right now .... | |
Receive-Job $Sender | out-host |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show-UI -Title 'FTP Log Search' { | |
Grid -Columns Auto,* -Rows 5 -Margin 5 -MinHeight 200 -MinWidth 250 { | |
Label "Date (MM/DD/YY)" | |
New-DatePicker -Name First -Column 1 -Margin "5" | |
Label "Clip Name" -Row 1 | |
New-TextBox -Name Last -Row 1 -Column 1 -Margin "5" | |
Label "E-mail Address" -Row 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module "D:\Coding\PowerShell\Modules\remove-OldFiles.psm1" | |
remove-OldFiles -Path 'D:\Coding' -ExcludeFolders "Bootstrap Learning","PowerShell","Waaah!" | |
#the folder Waaah! dont exists in the Folder mentioned above. so in the PSM there is a write-Host line to display this error. but i dont see it when i call the function from the ps1 script. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
$Source = "c:\users\USER1\desktop\test\folder1", | |
$Destination = "c:\users\USER1\desktop\test\folder2" | |
) | |
$Sources = Get-ChildItem $Source -recurse -depth 4 | Where-Object {$_.name -like "*``, *`` *``(*2016)"} | Select-Object -ExpandProperty FullName | |
Push-Location $Source | |
foreach($SourcePath in $Sources) { | |
$DestPath = Join-Path $Destination (Resolve-Path $SourcePath -Relative) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type @" | |
using System; | |
using System.Runtime.InteropServices; | |
public class NativeConsoleMethods | |
{ | |
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] | |
public static extern IntPtr GetStdHandle(int handleId); |
NewerOlder