Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block rohnedwards

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
rohnedwards / Test-DynamicParamCreation.ps1
Created May 18, 2018
Example of peeking into unbound parameters inside DynamicParam block. This is a bad idea, and should only be used for playing around with the PowerShell engine.
View Test-DynamicParamCreation.ps1
# Link to original question:
function Test-DynamicParamCreation {
Example of how to make dynamic param decisions based on other dynamic params.
NOTE: This probably isn't a good idea, as reflection is used to get at private
members of the PowerShell engine.
This function has a dynamic parameter named '-OtherDynamicParameterName' that
rohnedwards / DetectPreviousCommandArgCompleter.ps1
Created May 18, 2018
Example of ArgumentCompleter looking back in Command AST
View DetectPreviousCommandArgCompleter.ps1
# See here for question:
function Test-DetectProperty {
Proof of concept to show that inspecting preceding command elements is possible
from within ArgumentCompleters, at least in a limited way.
Get-Service | Test-DetectProperty -Property <PressTab>
View ConditionalAceTest.cs
This is meant to be saved as a .cs file, and called with Add-Type inside PowerShell:
Add-Type -Path c:\path\to\this\gist.cs
using System;
using System.Security.Principal;
using System.Collections.Generic;
using System.Linq;
rohnedwards / QueryServiceObjectSecurity.ps1
Last active Aug 29, 2015
Demo code for using QueryServiceObjectSecurity() Win32 call from PowerShell. Created in response to a comment from here:
View QueryServiceObjectSecurity.ps1
NOTE: I think you have to run this as an admin b/c ServiceHandle seems to
be null when not elevated. Also, this can't be used to get the SACL
(ServiceHandle probably isn't opened with that access requested, and
this code doesn't do privilege modifications). If you really want to
get around these problems, you can probably use reflection to get at
the GetServiceHandle() private method on the ServiceController
instance. That might work as a non-elevated user...
You can’t perform that action at this time.