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
# this works, but only if I import with using | |
class StringTransformAttribute : System.Management.Automation.ArgumentTransformationAttribute | |
{ | |
[object] Transform([System.Management.Automation.EngineIntrinsics]$EngineIntrinsics, [object]$InputData) | |
{ | |
return "a different string" | |
} | |
} | |
function Test-StringTransform |
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-JsonWhois | |
{ | |
[CmdletBinding(DefaultParameterSetName = "ip")] | |
param | |
( | |
[Parameter(Mandatory, ParameterSetName = "ip")] | |
[string] | |
$IPAddress, | |
[Parameter(Mandatory, ParameterSetName = "domain")] |
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
# default constructor - has no parameters | |
# method 1 - new and then set properties | |
$Configuration = [Foo.ConfigurationObject]::new() | |
$Configuration.Domain = $DomainName | |
$Configuration.Token = $Token | |
# method 2 - add properties via New-Object | |
$Configuration = New-Object Foo.ConfigurationObject -Property @{ | |
Domain = $DomainName |
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
$ControlPanelApplets = [ordered]@{ | |
"Add a Device wizard" = "$env:windir\System32\DevicePairingWizard.exe" | |
"Add Hardware wizard" = "$env:windir\System32\hdwwiz.exe" | |
"Add a Printer wizard" = "rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter" | |
"Administrative Tools" = "control.exe /name Microsoft.AdministrativeTools" | |
"AutoPlay" = "control.exe /name Microsoft.AutoPlay" | |
"Backup and Restore" = "control.exe /name Microsoft.BackupAndRestoreCenter" | |
"BitLocker Drive Encryption" = "control.exe /name Microsoft.BitLockerDriveEncryption" | |
"Color and Appearance" = "explorer shell:::{ED834ED6-4B5A-4bfe-8F11-A626DCB6A921} -Microsoft.Personalization\pageColorization" | |
"Color Management" = "control.exe /name Microsoft.ColorManagement" |
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
# desktop | |
"terminal.background": "#012456", | |
"terminal.foreground": "#F5F5F5" | |
# core | |
"terminal.background": "#141A25", | |
"terminal.foreground": "#F5F5F5" |
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
$Script = { | |
param([int]$MaxLength) | |
switch ($this) | |
{ | |
{[string]::IsNullOrEmpty($_)} {$this; break} | |
{$_.Length -le $MaxLength} {$this; break} | |
default {$_.SubString(0, $MaxLength)} | |
} | |
} |
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 -Path .\newtonsoft.json.dll | |
$CSharp = @" | |
namespace json | |
{ | |
public class demo | |
{ | |
public string prop1 {get; set;} | |
public int prop2 {get; set;} | |
public string[] prop3 {get; set;} |
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-cPath | |
{ | |
param | |
( | |
$Path | |
) | |
if (!([System.Io.File]::Exists($Path) -or [System.Io.Directory]::Exists($Path))) | |
{ | |
return $Path |
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
$TestValue = "nuffin" | |
switch ($TestValue) | |
{ | |
"sumpin" | |
{ | |
"this does not run" | |
} | |
"nuffin" |
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 ConvertFrom-RGB | |
{ | |
param | |
( | |
[Parameter(Mandatory)] | |
[ValidateCount(3,3)] | |
[Byte[]] | |
$RGB | |
) | |
NewerOlder