Skip to content

Instantly share code, notes, and snippets.

View sstorie's full-sized avatar

Sam Storie sstorie

  • SPS Commerce
  • Minnesota, USA
  • X @sstorie
View GitHub Profile
@sstorie
sstorie / WMI-CIM-CodeExamples.ps1
Created December 6, 2021 18:28 — forked from ScriptAutomate/WMI-CIM-CodeExamples.ps1
Examples of Using WMI/CIM Cmdlets
break #To prevent accidental execution of all commands
# WMI cmdlets: Work against anything, where DCOM RPC dynamic port range is available
# CIM cmdlets: Exist in PowerShell v3 and up, can use DCOM or WSMAN. Can have CimSessions. Microsoft going forward.
$Creds = Get-Credential
Get-WmiObject -Class win32_computersystem
Get-WmiObject -Class win32_computersystem -ComputerName server1 -Credential $Creds
Get-CimInstance -Class win32_computersystem -ComputerName server1 -Credential $Creds
$Session = New-CimSession -ComputerName server1 -Credential $Creds
Get-CimInstance -Class win32_computersystem -CimSession $Session
Get-CimSession
@sstorie
sstorie / GitVersionInfo.cs
Last active August 29, 2015 14:27
A simple class to expose the compiled attributes created by GitVersionTask easier to consume in .NET code.
namespace GitVersionInfo
/// <summary>
/// A simple wrapper to make the compiled GitVersionTask variables easily accessible.
///
/// Here is an example set of values
/// {
/// "Major":1,
/// "Minor":3,
/// "Patch":0,
/// "PreReleaseTag":"unstable.7",
@sstorie
sstorie / gist:2b47c33fc82b0784331f
Created January 20, 2015 21:12
Code to set up the ServiceLocatorProvider for use with MediatR
public static void Start()
{
var container = StructuremapMvc.StructureMapDependencyScope.Container;
// Create a new dependency resolver to use for this request, and save it so we can
// set up a service locator provider
//
var resolver = new StructureMapWebApiDependencyResolver(container);
GlobalConfiguration.Configuration.DependencyResolver = resolver;
public class DefaultRegistry : Registry {
#region Constructors and Destructors
public DefaultRegistry() {
Scan(
scan => {
scan.TheCallingAssembly();
// Ensure the assembly with our IMediator interface is loaded
//
@sstorie
sstorie / gist:752c249ee810cf1c986f
Created January 20, 2015 21:09
The output of StructureMap's container.WhatDoIHave()
==================================================================================================================================================================================================================================================================
PluginType Namespace Lifecycle Description Name
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Func<TResult> System Transient Open Generic Template for Func<> (Default)