Skip to content

Instantly share code, notes, and snippets.

rohnedwards

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
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: https://powershell.org/forums/topic/retrieve-the-input-value-of-the-dynamic-parameter/
function Test-DynamicParamCreation {
<#
.SYNOPSIS
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.
.DESCRIPTION
This function has a dynamic parameter named '-OtherDynamicParameterName' that
@rohnedwards
rohnedwards / DetectPreviousCommandArgCompleter.ps1
Created May 18, 2018
Example of ArgumentCompleter looking back in Command AST
View DetectPreviousCommandArgCompleter.ps1
# See here for question: https://rohnspowershellblog.wordpress.com/2017/01/17/completing-parameter-values-with-other-parameter-values/#comment-437
function Test-DetectProperty {
<#
.SYNOPSIS
Proof of concept to show that inspecting preceding command elements is possible
from within ArgumentCompleters, at least in a limited way.
.EXAMPLE
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
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: https://rohnspowershellblog.wordpress.com/2013/03/19/viewing-service-acls/
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.