Skip to content

Instantly share code, notes, and snippets.

[xml] $axml= Get-Content E:\Code\Library\DataLayer.csproj
$ns = new-object Xml.XmlNamespaceManager $axml.NameTable
$ns.AddNamespace("d", "http://schemas.microsoft.com/developer/msbuild/2003")
$nodes = $axml.SelectNodes( "/d:Project/d:ItemGroup/d:Reference", $ns)
foreach ($node in $nodes) {
$object = New-Object –TypeName PSObject
$object | Add-Member -MemberType NoteProperty –Name File –Value (split-path $path -leaf)
$object | Add-Member –MemberType NoteProperty –Name Name –Value $node.Include
$object | Add-Member –MemberType NoteProperty –Name Path –Value $node.HintPath
$lines = select-string -Path E:\Code\Application\Websit1.sln -Pattern "^Project.*"
$lines | % {
$pattern = "Project.*=\s`"([^`"]*)`", `"([^`"]*)"
if ([Regex]::IsMatch($_.Line, $pattern) ) {
$matches = [Regex]::Matches($_.Line, $pattern)
$name = $matches[0].Groups[1].Value
$path = $matches[0].Groups[2].Value
gci -Path E:\Code\ -Filter *.sln -Recurse | select Name, FullName
@johnmmoss
johnmmoss / Setup-Pester.ps1
Created April 28, 2017 09:28
cmdlet to setup pester
function Setup-Pester {
$ModulePath = "C:\Users\johnm\Documents\WindowsPowerShell\Modules"
$PesterModulePath = "$ModulePath\Pester"
if ((Test-Path $PesterModulePath) -eq $true) {
write-host Deleting Existing -ForegroundColor Gray
ri $PesterModulePath -Recurse -Force
}
@johnmmoss
johnmmoss / BuildSln.ps1
Created March 6, 2017 15:00
Powershell Function to Build a visual studio sln file
function Build-Sln() {
Param(
[parameter(ValueFromPipeline)]
[string] $slnPath
)
Process {
$msbuildExe = "C:\Windows\Microsoft.Net\Framework\v4.0.30319\msbuild.exe"
private static string ConvertMarkdown(string unsafeMarkdown)
{
var encodedMarkdown = HttpUtility.HtmlEncode(unsafeMarkdown);
var unsafeContent = CommonMark.CommonMarkConverter.Convert(encodedMarkdown);
var safeContent = new HtmlSanitizer().Sanitize(unsafeContent);
return safeContent;
}
@johnmmoss
johnmmoss / references.ps1
Created January 16, 2017 11:09
VisualStudio: Find all references for a library
(Get-Project -all).Object.References |
Where-Object { $_.Name -eq "Castle.Core" } |
Select-Object Identity, Path
@johnmmoss
johnmmoss / grep.ps1
Created January 16, 2017 11:07
Example grep command
gci D:\git\TimesheetsPoc -Recurse -Filter *.csproj | foreach {
write-host Processing $_.Name -ForegroundColor Green
Get-Content $_.FullName | select-string -Pattern "v10.0"
}
@johnmmoss
johnmmoss / tail.ps1
Created January 16, 2017 11:06
Example tail command
function tail (){
Param(
[string] $file,
[int] $last = 10
)
Get-Content $file | Select-Object -Last $last
}
@johnmmoss
johnmmoss / IdentiyConfig.cs
Created November 12, 2016 21:07
Sample Identiy Config
public class IdentityConfig
{
public void Configuration(IAppBuilder app)
{
app.CreatePerOwinContext(() => new TimesheetsContext());
app.CreatePerOwinContext<UserManager>(UserManager.Create);
app.CreatePerOwinContext<RoleManager<Role>>((options, context) =>
new RoleManager<Role>(
new RoleStore<Role>(context.Get<TimesheetsContext>())));