Skip to content

Instantly share code, notes, and snippets.

@a5ync
a5ync / RunningScriptDetails.ps1
Created April 20, 2016 00:53
Running script details - current path, name of the script (this)
## ScriptTest.ps1
Write-Host "InvocationName:" $MyInvocation.InvocationName
Write-Host "Path:" $MyInvocation.MyCommand.Path
@a5ync
a5ync / InstallNodeAppAsWindowsService.ps1
Created April 20, 2016 01:04
Powershell wrapper over NSSM (Non-Sucking Service Manager), to install Node app as a Windows-Service
#please read the NSSM https://nssm.cc/usage
Function Install-Service {
param(
[Parameter(Mandatory=$true)][string]$NSSMPath,
[Parameter(Mandatory=$true)][string]$serviceName ,
[Parameter(Mandatory=$true)][string]$serviceExecutable ,
[Parameter(Mandatory=$false)][string]$serviceExecutableArgs ,
[Parameter(Mandatory=$false)][string]$serviceAppDirectory ,
[Parameter(Mandatory=$true)][string]$serviceErrorLogFile ,
[Parameter(Mandatory=$true)][string]$serviceOutputLogFile ,
@a5ync
a5ync / CreateJSON.ps1
Created April 20, 2016 18:02
Create a JSON file
Write-host Preparing version file
$version="1.0.0"
$json = @"
{
"version": "$version",
"timestamp": "$(Get-Date)"
}
"@
[System.IO.File]::WriteAllLines("version.json", $json)
@a5ync
a5ync / listDNXPackages.ps1
Created May 6, 2016 00:27
List DNX packages installed in system
$path = "c:\Users\"+[Environment]::UserName+"\.dnx\packages"
write-host $path
function GetDirs($path = $pwd, [Byte]$ToDepth = 255, [Byte]$CurrentDepth = 0)
{
$CurrentDepth++
If ($CurrentDepth -le $ToDepth) {
foreach ($item in Get-ChildItem $path)
{
if (Test-Path $item.FullName -PathType Container)
class ResourceHelper
{
public static string GetScriptFromResources(string resourceName)
{
var assembly = Assembly.GetExecutingAssembly();
string scriptBody = null;
//lists all the embedded resources
//var resources = assembly.GetManifestResourceNames();
@a5ync
a5ync / injectGitHashToProjectJson.ps1
Created March 15, 2017 21:30
TeamCity: Inject github short hash to project.json files of aspnet core
$rootDirectory="%teamcity.build.workingDir%"
$gitHash="%build.vcs.number%"
echo "githash is $gitHash"
$gitShortHash=$gitHash.Substring(0,7)
$listOfFiles = @(
"$rootDirectory\src\TestProject\project.json"
)
foreach($file in $listOfFiles)
@a5ync
a5ync / injectGitHashToAssemblyInfo.ps1
Created March 15, 2017 21:32
TeamCity: Inject github short hash to AssemblyInfo.cs files
$githubHash="%build.vcs.number%"
$gitShortHash=$githubHash.Substring(0,7)
$rootDirectory="%teamcity.build.workingDir%"
$listOfFiles = @(
"$rootDirectory\TestProject\Properties\AssemblyInfo.cs"
)
foreach($file in $listOfFiles)
{
@a5ync
a5ync / removePdbFiles.ps1
Created March 23, 2017 00:27
TeamCity: Removing recursively *.pdb
Get-ChildItem -Path "%teamcity.build.workingDir%" -Filter *.pdb -Recurse|Remove-Item -force
@a5ync
a5ync / CityMaps.cs
Created March 24, 2017 07:10
Average city temperatures in CS
class Program
{
public class CityTemps
{
public string City { get; set; }
public string Year { get; set; }
public double Temp { get; set; }
}
static void Main(string[] args)
@a5ync
a5ync / generateDllVersionLog.ps1
Created March 27, 2017 22:29
Generate file with all the versions of assemblies included in project
Param(
[Parameter(Mandatory=$true)][string]$sourceDirectory,
[Parameter(Mandatory=$true)][string]$outputFile
)
#$sourceDirectory = "c:\temp\container-builder\"
#$outputFile = "c:\temp\container.txt"
$files= Get-ChildItem $sourceDirectory -Filter *.dll