Skip to content

Instantly share code, notes, and snippets.

View Stephanevg's full-sized avatar
:octocat:
I like computers

Van Gulick Stephanevg

:octocat:
I like computers
View GitHub Profile
@jborean93
jborean93 / Add-WinRMDaclRule.ps1
Created June 20, 2019 21:23
Adds a rule to the WinRM DACL list
Function Add-WinRMDaclRule {
<#
.SYNOPSIS
Add a Discretionary Acl rule to the root WinRM listener or individual PSSession configuration.
.DESCRIPTION
Add a Discretionary Acl rule to the root WinRM listener or individual PSSession configuration.
This can be useful if you wish to give access to an individual user or group to either the root WinRM listener or
a specific PSSession configuration that is not an Administrator.
@nohwnd
nohwnd / scopechecks.ps1
Created December 12, 2018 15:54
Shared state between DSL keywords in Pester
# in module scope
$script:pester
function describe () {
$script:pester.EnterBlock("describe")
}
function it () {
// Discord all events!
// A quick and dirty fleshing out of the discord.js event listeners (not tested at all!)
// listed here -> https://discord.js.org/#/docs/main/stable/class/Client
// Learn from this, do not just copy it mofo!
//
// Saved to -> https://gist.github.com/koad/316b265a91d933fd1b62dddfcc3ff584
// Last Updated -> Halloween 2022
/*
@Jaykul
Jaykul / ValidateUnique.md
Last active May 7, 2022 01:13
Validating PowerShell class properties

The simplest way to enforce rules on PowerShell class properties is to set the Type of the property, of course. But sometimes you want something a little bit more clever than that. One solution is to use a Validate* attribute, like ValidateRange or ValidateLength or ValidateSet attribute...

However, you can write your own, by just deriving from ValidateArguments() or something that derives from that, like the ValidateEnumeratedArguments class allows you to validate a whole array of items.

For instance, a simple validator would be one that validates uniqueness, based on a specific property. Our validator will be created fresh each time it's used, and then each item in the array will be passed through ValidateElement, so this works:

using namespace System.Collections.Generic
usin