This file contains 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 Set-GPOStatus | |
{ | |
<# | |
.Synopsis | |
Set the status of a Group Policy Object | |
.Description | |
Sets the status of one or more Group Policy objects. | |
.Example | |
PS C:\> Get-Gpo MyGPO | Set-GPOStatus -Status AllSettingsEnabled | |
.Example |
This file contains 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 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 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 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 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 a simple array | |
$Items = @( | |
[PSCustomObject]@{Name = 'Item1'; SomeProperty = "1"}, | |
[PSCustomObject]@{Name = 'Item2'; SomeProperty = "2"}, | |
[PSCustomObject]@{Name = 'Item3'; SomeProperty = "3"} | |
) | |
### enumerate a property of the objects passed in via -ArgumentList | |
# the output here is always '2' |
This file contains 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 Add-TaskbarItem | |
{ | |
<# | |
.SYNOPSIS | |
Adds or removes items from a user's taskbar | |
.DESCRIPTION | |
Adds or removes items from a user's taskbar. Supports pinning of multiple items using the pipeline. | |
.PARAMETER Action |
This file contains 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 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 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