Browse by Tags

  • Get closure with GetNewClosure

    Have you ever created scriptblocks on the fly, say in a foreach loop, and they totally mess up because they all have the same value? This is something sort of advanced, and typically used when you’re proxying an object. The most basic example would be, taken from ( http://www.powershellcommunity.org/Forums/tabid/54/aff/1/aft/2506/afv/topic/Default.aspx ) function add([int]$x) { return { param([int...
  • Tied Variables in PowerShell

    With Add-Type and $executioncontext you can add special varibles that have tied values. I made $random, and $now add-type @" using System; using System.Management.Automation; public class RandomVariable : PSVariable { Random r; public RandomVariable () : base("Random", 0, ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope) {r = new Random();} public override object Value { get Read...
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.