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
# Set up the proxy forwarder ... | |
Add-Type -path .\NetMQ\lib\net40\NetMQ.dll | |
Start-Job { | |
try { | |
$context = [NetMQ.NetMQContext]::Create() | |
$publisher = $context.CreateXPublisherSocket() | |
$subscriber = $context.CreateXSubscriberSocket() | |
$publisher.Bind("tcp://127.0.0.1:50007"); |
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
$Processor, $Privileged = Get-CounterLocalizedName "Processor", "% Privileged Time" | |
Get-Counter "\$Processor(_Total)\$Privileged" |
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
@{ | |
ModuleVersion = '1.0' | |
RequiredModules = 'ShowUI' | |
RequiredAssemblies = '.\lib\net40\MahApps.Metro.dll' | |
ModuleToProcess = 'MahApps.Metro.psm1' | |
GUID = '36f28fcd-90dc-4278-9baa-b8544a032d84' | |
FunctionsToExport = @('New-CloseTabItemAction','New-SetFlyoutOpenAction','New-BindableResourceBehavior','New-BorderlessWindowBehavior','New-GlowWindowBehavior','New-WindowsSettingBehaviour','New-CustomValidationPopup','New-DataGridNumericUpDownColumn','New-LoginDialogSettings','New-CustomDialog','New-DropDownButton','New-FlipViewItem','New-FlipView','New-Flyout','New-FlyoutsControl','New-Glow','New-LayoutInvalidationCatcher','New-MetroAnimatedSingleRowTabControl','New-MetroAnimatedTabControl','New-MetroWindow','New-MetroNavigationWindow','New-MetroProgressBar','New-MetroTabControl','New-MetroTabItem','New-MultiFrameImage','New-NumericUpDown','New-Pivot','New-PivotItem','New-ScrollViewerOffsetMediator','New-SplitButton','New-WindowButtonCommands','New-WindowCommands','New-Planerator','New-ProgressRi |
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
&{ | |
[CmdletBinding()]param() | |
&{[CmdletBinding()]param() Write-Error "Demo Error 1" } -EA 0 -EV e; | |
$PSCmdlet.WriteError($e[0]); | |
1/0 | |
&{[CmdletBinding()]param() Write-Error "Demo Error 2" } -EA 0 -EV e; | |
$PSCmdlet.ThrowTerminatingError($e[0]) |
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
[324]: try { | |
路 try{ | |
路 throw [System.Management.Automation.ParameterBindingException]::new( "whatever", | |
路 [System.Management.Automation.ItemNotFoundException]::new("File Not Found")) | |
路 } catch{ throw $_} | |
路 } catch [System.Management.Automation.ParameterBindingException] { "PBE" } | |
路 catch [System.Management.Automation.ItemNotFoundException] { "INFE" } | |
PBE | |
[325]: |
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 Stop-ChildProcess { | |
[CmdletBinding(SupportsShouldProcess=$true)] | |
param( | |
[Parameter(ValueFromPipelineByPropertyName=$true, ParameterSetName="Name")] | |
[String[]]$Name, | |
[Parameter(ValueFromPipelineByPropertyName=$true, ParameterSetName="ID")] | |
[Alias("ProcessID")] | |
[Int[]]$ID, |
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 Tail-File { | |
[CmdletBinding()] | |
param($Path, | |
[System.Text.Encoding]$Encoding = $([System.Text.Encoding]::UTF8) | |
) | |
$File = Convert-Path $Path | |
try { | |
$Stream = New-Object System.IO.FileStream $File, "Open", "Read", "ReadWrite", 2048, "None" | |
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
[CmdletBinding()] | |
param( | |
# If you want to try the bing images from other countries, fiddle around with this (try en-GB, for instance) | |
$Culture = 'en-US', | |
# If you want to (re)use yesterday's wallpapers, fiddle around with this | |
$Offset = 0 | |
) | |
Add-Type -Assembly System.Windows.Forms, PresentationFramework | |
Add-Type -Name Windows -Namespace System -MemberDefinition @' |
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
#requires -Module PackageManagement | |
using namespace NuGet | |
[CmdletBinding(DefaultParameterSetName = 'MaybeUseExisting')] | |
param( | |
[Parameter(Mandatory, Position = 0)] | |
[String]$Name, | |
[String]$Destination = "$(Split-Path $Profile)\Libraries", | |
[switch]$ForceReinstall, |
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
#4 I call this one: where the bleep did they put the cheese? | |
function Get-FileException { | |
param($Path) | |
# Assume I'm doing something with files and it throws this exception: | |
$fnf = [System.IO.FileNotFoundException]::new("File Not Found", $Path) | |
$inf = [System.Management.Automation.ItemNotFoundException]::new( "Item Not Found", $fnf) | |
throw $inf | |
} |