Skip to content

Instantly share code, notes, and snippets.

@sean-m
sean-m / SetupStringAttributeStore.ps1
Created December 6, 2018 00:19
Compiles ADFS StringProcessingAttributeStore as documented on MSDN with an added capability to check bitfield flags.
#Requires -Version 4 -Module ADFS
<#
Compiles ADFS StringProcessingAttributeStore from here:
https://msdn.microsoft.com/en-us/library/hh599320.aspx?f=255&MSPPError=-2147217396
* Notice: must be run as Admin, will prompt UAC *
Steps taken:
1. download dependency from nuget
@sean-m
sean-m / MIM_Sync_Perf.hta
Last active September 28, 2018 18:55
Simple HTA app providing a perfmon dashboard for FIM/MIM/AAD Sync management agents. Helps with troubleshooting sync performance issues.
<html>
<head>
<!-- Note: needs to be run as admin. Use cmd or pshell to bootstrap or compile to exe with vbsedit. -->
<title>MIM Sync Perf Counters</title>
<HTA:APPLICATION
APPLICATIONNAME="MIM Sync Perf Counters"
ID="MyHTMLapplication"
VERSION="1.0"/>
</head>
<SCRIPT LANGUAGE="VBScript">
@sean-m
sean-m / html5snark.ps1
Last active January 15, 2021 23:22
Quick easy script for packaging video as base64 encoded html. Depends on ffmpeg, doesn't do error handling. It's not supposed to be robust, it's to lower the bar for harrassing my coworkers.
param ($file, $output, $title, [switch]$fragment)
function FileToBase64 {
[Alias("tb64")]
param ([string]$Path)
[Convert]::ToBase64String([IO.File]::ReadAllBytes($Path))
}
$rnd = Get-Random -Minimum 1 -Maximum 98029839879
@sean-m
sean-m / GetMIMReference.ps1
Created July 2, 2018 19:20
Code for resolving MIM property references with some caching to optimize network roundtrips.
#Requires -Modules LithnetRMA
Import-Module LithnetRMA
Set-ResourceManagementClient -BaseAddress http://mimservice:5725
$default_attr = @("DisplayName","Description","Creator")
function GetAttrsByType {
<#
Resolves list of attributes that should be loaded for a provided type.
@sean-m
sean-m / Repair_Owner_DisplayOwner_Mismatch.ps1
Created February 21, 2018 01:32
Queries for Group objects that have the Owner attribute set but who's DisplayedOwner is not in the Owner list.
#Requires -Version 4 -Modules FIM\FimPowerShellModule.psm1
<#
Queries for Group objects that have the Owner attribute set but who's DisplayedOwner
is not in the Owner list. This can occur you have a FIM/MIM Sync Rule that maps
managedBy => DisplayedOwner and msExchCoManagedByLink => Owner. Those attributes will
flow directly because they match up being single => single, multivalue => multivalue but
there is the caveat that the managedBy value never has a reason to exist in the msExchCoManagedByLink
value. Setting the FIM Group Owner list by combining the two source attributes doesn't appear to work
via declarative rule or rule extension but allowing the properties to Sync directly and then resolving
@sean-m
sean-m / convert_rdg_to_mremote.ps1
Last active January 23, 2018 23:35
Reads in an RDCMan 2.7 connection file (.rdg) and generates an approximate mRemote connections file. I say approximate because it doesn't handle things like color depth or RDGateway configuration. It's not perfect but way better than recreating it by hand in an environment with 100+ servers.
<#
Reads in an RDCMan 2.7 connection file (.rdg) and generates an approximate
mRemote 1.75 connections file. I say approximate because it doesn't handle
color depth or complete RDGateway configuration. It's not perfect but way
better than recreating it by hand in an environment with 100+ servers.
Cheers.
-Sean McArdle
#>
@sean-m
sean-m / Get_MA.ps1
Created November 28, 2017 06:01
PowerShell function for retreiving a FIM/MIM Sync Management Agent object.
function Get-Ma {
param (
[string]$Name,
[string]$Guid
)
$search_string = ""
if ([String]::IsNullOrEmpty($Name) -and [String]::IsNullOrEmpty($Guid)) {
throw "Must pass management agent Name or Guid"
}
@sean-m
sean-m / ShowObjectGraph.ps1
Last active January 3, 2021 07:04
Displays structure of an object/collection in a WPF TreeView.
function Show-ObjectGraph {
[Alias('sog')]
<#
.Synopsis
Displays structure of an object/collection in a WPF TreeView.
.DESCRIPTION
Recursively builds out an object graph which is then set to
the DataContext of a WPF TreeView. This will display all type and
member info for the object or collection elements. This is a blocking
operation.
@sean-m
sean-m / GenDirectoryEntryWrapper.ps1
Created September 22, 2017 17:48
Script that generates C# object properties that lazy load from a private DirectoryEntry (_de) field. Input text file is: [property type] [property name].
function GenProp {
param ($type, $name)
if ($type -like 'bool' `
-or $type -like 'int' ) {
$_default = $null
switch ($type) {
'bool' {
$_default = 'false'
}
@sean-m
sean-m / Ternary.ps1
Last active August 25, 2017 19:08
My take on a ternary operation for PowerShell, I use it for my stuff and make no promises. Enjoy!
<#
.Synopsis
Ternary operation for PowerShell with terse
parameter aliases. Meant to be used from pipeline.
.Example
gci -Recurse | >> {$_.PSIsContainer} "Directory" "File"
.Example
1..10 | >> {($_ % 2) -eq 0} "Even" "Odd"
.Example
# Pass through numbers greater than 0 or print 0