Skip to content

Instantly share code, notes, and snippets.

View mgreenegit's full-sized avatar

Michael Greene mgreenegit

  • Microsoft
View GitHub Profile
@mgreenegit
mgreenegit / ResourceSample.psm1
Created April 30, 2022 19:48
An example DSC resource where only the functions need to be edited
# This is the Get function
function Get-Resource {
param(
[Parameter(Mandatory = $true)]
[String]
$Ensure,
[Parameter(Mandatory = $true)]
[string]
$PropertyA,
[Parameter(Mandatory = $true)]
@mgreenegit
mgreenegit / ResourceSample2.psm1
Created May 3, 2022 16:31
Simple example of class resource for Windows service
# This is the Get function
function Get-Resource {
param(
[string]$status,
[string]$starttype
)
$service = Get-Service winmgmt
# Information returned by Get will be available in Azure via API
return @{
@mgreenegit
mgreenegit / NetFirewallDsc Example
Last active August 5, 2022 13:48
TODO: add enum for gposetting type, try splitting details into a reasons array
function Get-Resource {
param(
[DscProperties]$DscProperties
)
$psPath = Join-Path ([System.Environment]::SystemDirectory) 'WindowsPowerShell\v1.0\powershell.exe'
& $psPath -noProfile -command {
param(
$Name
)
$Env:PSModulePath += ";$PSHOME\Modules\NetSecurity"
@mgreenegit
mgreenegit / show.ps1
Created September 15, 2022 15:18
PS slideShow
function wait { $null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') }
function line { write-host '' }
function getslides {param([string]$path) Get-Childitem -Path $path -Filter slide*.md}
function slide {
param(
[string]$path
)
$slides = getslides $path
foreach ($i in 0..$slides.count) {
$slide = Join-Path $path slide$i.md
@mgreenegit
mgreenegit / pocARGCompleter.ps1
Created September 23, 2022 16:15
POC ARG Completer
function smartComplete {
param ( $commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameters )
$possibleValues = [array](Search-AzGraph -Query "resourcecontainers | where ['type'] == 'microsoft.resources/subscriptions' | project name").name
if ($fakeBoundParameters) {