Skip to content

Instantly share code, notes, and snippets.

View ducas's full-sized avatar

Ducas Francis ducas

  • Readify
  • Sydney, Australia
View GitHub Profile
@ducas
ducas / New-UncVirtualDirectory.ps1
Created December 17, 2014 21:48
Create a virtual directory that is mapped to a UNC
$virtualPath = "vdir"
$physicalPath = "\\server\share"
$parentSite = "Default Website"
$username = "share_user"
$password = "share_password"
Add-PSSnapin WebAdministration -ErrorAction SilentlyContinue
Import-Module WebAdministration -ErrorAction SilentlyContinue
Write-Host "Getting web site $parentSite."
@ducas
ducas / Set-LocalAccountPassword.ps1
Last active January 19, 2018 15:27
Change a local user account's password using PowerShell
$Username = "su"
$Password = "password"
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
$existing = $adsi.Children | where {$_.SchemaClassName -eq 'user' -and $_.Name -eq $Username }
if ($existing -eq $null) {
Write-Error "User $Username does not exist"
return
}
@ducas
ducas / Create-Administrator.ps1
Last active January 14, 2024 07:18
Create a local administrator account using PowerShell
$Username = "su"
$Password = "password"
$group = "Administrators"
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
$existing = $adsi.Children | where {$_.SchemaClassName -eq 'user' -and $_.Name -eq $Username }
if ($existing -eq $null) {
@ducas
ducas / jquery.preventNavigation.js
Last active August 29, 2015 14:09
Confirm Navigation Dialog
(function ($) {
$.fn.preventNavigation = function () {
var that = this;
this.on('change', 'input, select, textarea', function () {
that.data('field-change', true);
});
this.on('submit', function () {
@ducas
ducas / InMemoryIssuerNameRegistry.cs
Created September 5, 2014 01:27
In-Memory Issuer Name Registry Implementation for WAAD
using System.Collections.Generic;
using System.IdentityModel.Tokens;
using System.Linq;
using Web.Models;
namespace Web.Utils
{
public class InMemoryIssuerNameRegistry : ValidatingIssuerNameRegistry
{
public class TenantData
@ducas
ducas / Octopus-Umbraco.psm1
Last active August 29, 2015 14:04
Umbraco helpers for Octopus Deploy
function Set-UmbracoPermissions($SitePath, $AppPoolAccount, $PathOverrides)
{
$readExecute = $AppPoolAccount,"ReadAndExecute","ContainerInherit, ObjectInherit","None","Allow"
$read = $AppPoolAccount,"Read","ContainerInherit, ObjectInherit","None","Allow"
$modify = $AppPoolAccount,"Modify","ContainerInherit, ObjectInherit","None","Allow"
$fileModify = $AppPoolAccount,"Modify","Allow"
$objects = @{}
$objects["App_Browsers"] = $readExecute
$objects["App_Code"] = $modify
@ducas
ducas / Validate-ReleaseAndPackagesForEnvironment.ps1
Last active August 29, 2015 14:03
Validate that a release and its packages can be deployed to an environment based on whether they have pre-release version numbers
$environment = $OctopusParameters['Octopus.Environment.Name']
$releaseNumber = $OctopusParameters['Octopus.Release.Number']
$packages = @(
@{
"Id" = $OctopusParameters['Octopus.Action[Update Database].Package.NuGetPackageId'];
"Version" = $OctopusParameters['Octopus.Action[Update Database].Package.NuGetPackageVersion']
},
@{
"Id" = $OctopusParameters['Octopus.Action[Deploy Website].Package.NuGetPackageId'];
"Version" = $OctopusParameters['Octopus.Action[Deploy Website].Package.NuGetPackageVersion']
@ducas
ducas / Initialize-Tentacle.ps1
Created June 17, 2014 22:46
Initialize an Octopus Deploy Tentacle by downloading, installing and setting up the Tentacle software
$OctopusThumbprint = "YOUR_THUMBRPRINT"
$OctopesServer = "http://your.octopusserver.com"
$ApiKey = "YOUR_API_KEY"
$Role = "a-role"
$Environment = "UAT"
$TentacleDownloadUrl = "http://octopusdeploy.com/downloads/latest/OctopusTentacle64"
$InstallDirectory = "C:\Program Files\Octopus Deploy\Tentacle"
@ducas
ducas / MongoApiController.cs
Created April 10, 2014 23:53
Generic WebAPI controller to provide a REST interface for MongoDB collections
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
namespace Web.Core
{
public abstract class MongoApiController<T> : ApiController
@ducas
ducas / CamelCaseStringEnumConverter.cs
Created April 8, 2014 23:13
ASP.Net Web API + JSend
using Newtonsoft.Json.Converters;
namespace Web.Core
{
public class CamelCaseStringEnumConverter : StringEnumConverter
{
public CamelCaseStringEnumConverter()
{
CamelCaseText = true;
}