This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace System | |
{ | |
public static class DateTimeExtensions | |
{ | |
public static string ToIso8601String(this DateTime thisDateTime) | |
{ | |
return thisDateTime.ToString("yyyy-MM-ddTHH:mm:ss.fffK"); | |
} | |
public static string ToIso8601String(this DateTimeOffset thisDateTime) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
$CommandName | |
) | |
[System.Management.Automation.ProxyCommand]::Create( | |
(New-Object System.Management.Automation.CommandMetaData (Get-Command $CommandName))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add reference to project: | |
// <Reference Include="Microsoft.PowerShell.ConsoleHost"/> | |
// <Reference Include="System.Management.Automation"/> | |
class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
ConsoleShell.Start(RunspaceConfiguration.Create(),bannerText:"Powershell Host",helpText:string.Empty, args:args); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function elevated { | |
<# | |
.SYNOPSIS | |
Runs a scriptblock in an elevated shell | |
.DESCRIPTION | |
A given script block is executed in a an elevated powershell, if the current host isn't elevated. | |
The elevated shell location is moved to the current directory. A profiole isn't loaded for the | |
elevated shell because of performance reasons. | |
The output of the shell is captured and exported as CLI-Xml to a temorary file and imported by the | |
original shell after the the elevated process ended. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Make a download with webclient using the DefaultNetworkCredentials to authenticate at proxy. | |
Afterwards all new webclient based cmdlets can pass the proxy. | |
.DESCRIPTION | |
Make a download with webclient using the DefaultNetworkCredentials to authenticate at proxy. | |
Afterwards all new webclient based cmdlets can pass the proxy. | |
.EXAMPLE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace Memoization | |
{ | |
public static class Memoize | |
{ | |
#region Create memoization containers | |
public interface IContainerFactory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from c:/Program Files (x86)/ReferenceAssemblies/Microsoft/WindowsPowershell/Microsft.PowerShell.ConsoleHost.Dll | |
using Microsoft.PowerShell; | |
// from c:/Program Files (x86)/ReferenceAssemblies/Microsoft/WindowsPowershell/System.Management.Automation.Dll | |
using System.Management.Automation; | |
using System.Management.Automation.Runspaces; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class ScopeGuard : IDisposable | |
{ | |
#region Construction and initialization of this instance | |
public static ScopeGuard WithOnLeave(Action onLeave) | |
{ | |
return new ScopeGuard(onLeave); | |
} | |
private ScopeGuard(Action onLeave) |
NewerOlder