Skip to content

Instantly share code, notes, and snippets.

function transform($xml, $xdt, $output)
{
Add-Type -LiteralPath "Microsoft.Web.XmlTransform.dll"
$xmldoc = New-Object Microsoft.Web.XmlTransform.XmlTransformableDocument;
$xmldoc.PreserveWhitespace = $true
$xmldoc.Load($xml);
$transform = New-Object Microsoft.Web.XmlTransform.XmlTransformation($xdt);
if ($transform.Apply($xmldoc) -eq $false)
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"webAppName": {
"type": "string"
},
"appServicePlanName": {
"type": "string"
},
// Add references to the following assemblies:
// System.Windows.Forms
// UIAutomationClient
// UIAutomationTypes
using System.Windows.Automation;
using System.Windows.Forms;
// Portions of code adapted from http://www.mathpirate.net/log/2009/09/27/swa-straight-outta-redmond/
public static void HandleAuthenticationDialogForIE(string userName, string password)
@nshenoy
nshenoy / HandleAuthenticationDialogForIE.cs
Last active December 13, 2015 21:38
UIAutomation code to handle the Windows Security dialog when testing in Internet Explorer
// Add references to the following assemblies:
// System.Windows.Forms
// UIAutomationClient
// UIAutomationTypes
using System.Windows.Automation;
using System.Windows.Forms;
// Portions of code adapted from http://www.mathpirate.net/log/2009/09/27/swa-straight-outta-redmond/
public static void HandleAuthenticationDialogForIE(string userName, string password)
public static class PowershellExtensions
{
public static Collection<PSObject> InvokeCommandAndRestoreDefaultTraceListener(this Pipeline pipeline)
{
bool hasDefaultTraceListener = PowershellExtensions.IsDefaultTraceListenerPresent();
Collection<PSObject> results = pipeline.Invoke();
if(hasDefaultTraceListener && !PowershellExtensions.IsDefaultTraceListenerPresent())
{
InitialSessionState state = InitialSessionState.CreateDefault();
state.ImportPSModule(new string[] { "DistributedCacheAdministration", "DistributedCacheConfiguration" });
state.ThrowOnRunspaceOpenError = true;
using(Runspace rs = RunspaceFactory.CreateRunspace(state))
{
rs.Open();
using(Pipeline pipeline = rs.CreatePipeline())
{