This file contains 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
#Audit script | |
$auditFile = "audit.txt" | |
$computername = "." #i.e local machine | |
"Computer name $computername" > $auditFile | |
"Computer details:" >> $auditFile | |
get-wmiobject Win32_ComputerSystem -computername $computername | | |
select Name, Manufacturer, Model,` | |
NumberOfProcessors, TotalPhysicalMemory, ` |
This file contains 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
#Version checks | |
#Version type | |
function Test-VersionIsGreaterThanOrEqualTo() | |
{ | |
param ([string] $versionA, [string] $versionB) | |
"versionA $versionA" | |
"versionB $versionB" | |
$version1 = New-Version $versionA |
This file contains 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
$projectSummarys = @{} | |
Get-ChildItem -exclude '*Test*' -Recurse -Include *.csproj | | |
Where-Object {$_.Attributes -ne "Directory"} | | |
%{ | |
$filename = $_.FullName | |
$proj = [xml](get-Content $filename); | |
$projectSummarys[$filename] = ($proj.Project.PropertyGroup)|select -Skip 1 -First 1 | | |
select WarningLevel, CodeAnalysisRuleSet, RunCodeAnalysis, TreatWarningsAsErrors | |
} |
This file contains 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
#Get the svn externs for all folders and provide a distinct list | |
$svnDirectory="c:\sg\programfiles\svn\1.6.6.40053" #NOTE : put your svn path here | |
$svnExe="$svnDirectory\svn.exe" | |
$externs = & $svnExe propget svn:externals -R | |
$externs | sort | Get-Unique >> DistinctSvnExternal.txt #Raw file | |
$uniqueDependencies = @{}; | |
$externs | sort | Get-Unique | |
This file contains 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 static class Random | |
{ | |
private static readonly System.Random rand = new System.Random(); | |
public static int Int(int maxValue = int.MaxValue) | |
{ | |
return rand.Next(maxValue); | |
} | |
public static bool Bool() | |
{ |
This file contains 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
void Main() | |
{ | |
var instanceName = "LINQPad"; | |
var counterCollectionInterval = TimeSpan.FromSeconds(1); | |
var continueCollectingTimeFrame = TimeSpan.FromSeconds(10); | |
var counters = from performanceCounterDefinition in PerformanceCounterRepository.GetPerfCounters | |
from counterName in performanceCounterDefinition.Counters | |
select new { |
This file contains 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 Stop-Nirvana{ | |
Get-Service | | |
Where {($_.Name -like "*nirvana*") -and ($_.Status -ne "Stopped")} | | |
Stop-Service | |
} | |
function Start-Nirvana{ | |
Get-Service | | |
Where {($_.Name -like "*nirvana*") -and ($_.Status -eq "Stopped")} | | |
Start-Service |
This file contains 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
#config swapper | |
#load the default values in to a hash | |
#get the values from the env and override in the hash | |
#foreach key in the hash replace the {[key]} with the value i.e. (Get-Content $_) -replace "$tokenedKey","$value" | Set-Content -path $_.$env | |
function Create-ConfigFromTemplate{ | |
param ([string]$envPropFile, #".\$env.properties" | |
[string]$outputFolder,#".\$env\ | |
[string]$templateFile #".\App.template.config" | |
) | |
This file contains 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 Get-ChildFolderTotalSize | |
{ | |
param($parentDir) | |
$children = (Get-ChildItem $parentDir | Where-Object {$_.PSIsContainer -eq $True} | Sort-Object) | |
$results = @(); | |
foreach ($i in $children) | |
{ | |
$childSum = (Get-ChildItem $i.FullName -recurse | Measure-Object -property length -sum) | |
$results += New-Object Object | |
This file contains 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 Select-UniqueChildrenWithStringPattern { | |
param($path, $pattern) | |
Get-ChildItem $path -Recurse | | |
Select-String -Pattern $pattern | | |
Select-Object Path | | |
Get-Unique | |
} | |
function String-ReplaceRecursive { | |
param($path, $pattern, $replaceValue) |