Skip to content

Instantly share code, notes, and snippets.

Avatar

EbenZhang EbenZhang

  • Nicologies
  • Perth
View GitHub Profile
@EbenZhang
EbenZhang / RestoreSQLServerDBUsingSMOInPowershell.ps1
Last active Sep 24, 2019
Restore SQLServer Database using Powershell and SMO
View RestoreSQLServerDBUsingSMOInPowershell.ps1
$ErrorActionPreference = "Stop"
$assemblylist =
"Microsoft.SqlServer.Management.Common",
"Microsoft.SqlServer.Smo",
"Microsoft.SqlServer.Dmf ",
"Microsoft.SqlServer.Instapi ",
"Microsoft.SqlServer.SqlWmiManagement ",
"Microsoft.SqlServer.ConnectionInfo ",
"Microsoft.SqlServer.SmoExtended ",
"Microsoft.SqlServer.SqlTDiagM ",
@EbenZhang
EbenZhang / CallGitHubApi.ps1
Last active Apr 6, 2019
Powershell to call GitHub Api using personal token
View CallGitHubApi.ps1
function CreateGitHubRequestHeaders([string]$username, [string]$token){
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$token)))
$headers = @{Authorization="Basic $base64AuthInfo"}
return $headers
}
function GetRestfulErrorResponse($exception) {
$ret = ""
if($exception.Exception -and $exception.Exception.Response){
@EbenZhang
EbenZhang / FindConflictingReferences.cs
Created Oct 26, 2015 — forked from brianlow/FindConflictingReferences.cs
Find conflicting assembly references
View FindConflictingReferences.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
namespace MyProject
{
[TestFixture]