Skip to content

Instantly share code, notes, and snippets.

View LindnerBrewery's full-sized avatar

Emrys MacInally LindnerBrewery

  • Karlsruhe, Germany
View GitHub Profile
@LindnerBrewery
LindnerBrewery / Test-TransformationClasses.ps1
Last active January 10, 2024 10:13
Transformation class example
# transformation class that transforms string to service controller object
class ServiceSingleTransformation : System.Management.Automation.ArgumentTransformationAttribute {
[object] Transform([System.Management.Automation.EngineIntrinsics]$EngineIntrinsics, [object] $InputData) {
$item = $InputData
if ($item -is [string]) {
$item = Get-Service -name "$item"
}elseif ($item -is [System.ServiceProcess.ServiceController]) {
$item = $item
}else {
@LindnerBrewery
LindnerBrewery / ConvertTo-SemVersion.Tests.ps1
Last active January 8, 2024 11:15
ConvertTo-SemVersion
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Scope='Function')]
Param()
BeforeAll {
. $PSCommandPath.Replace('.Tests.ps1','.ps1')
}
Describe "ConvertTo-SemVersion Tests" {
Context "When providing a valid version" {
It "Should normalize version 1 to 1.0.0" {
$version = "1"
@LindnerBrewery
LindnerBrewery / docker-compose.yml
Created November 30, 2022 11:36 — forked from ju2wheels/docker-compose.yml
docker-compose reference YAML file with comments
# https://docs.docker.com/compose/yml/
# Each service defined in docker-compose.yml must specify exactly one of
# image or build. Other keys are optional, and are analogous to their
# docker run command-line counterparts.
#
# As with docker run, options specified in the Dockerfile (e.g., CMD,
# EXPOSE, VOLUME, ENV) are respected by default - you don't need to
# specify them again in docker-compose.yml.
#
service_name:
@LindnerBrewery
LindnerBrewery / Get-NormalizedVersion.Tests.ps1
Last active November 17, 2022 09:10
Get-NormalizedVersion
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Scope='Function')]
Param()
BeforeAll {
. $PSCommandPath.Replace('.Tests.ps1','.ps1')
}
Describe Get-NormalizedVersion -Tag Unit{
Context 'Basic tests' {
It "1 -> 1.0.0" {
Get-NormalizedVersion 1 | Should -Be '1.0.0'
@LindnerBrewery
LindnerBrewery / Start-ProcessPlus.Tests.ps1
Last active November 14, 2022 09:19
Start-ProcessPlus
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Scope='Function')]
Param()
BeforeAll {
. $PSCommandPath.Replace('.Tests.ps1','.ps1')
}
Describe Start-ProcessPlus {
Context 'Basic tests' {
It "Invoking ping on localhost. This should always work" {
$result = Start-ProcessPlus -FilePath ping.exe -ArgumentList 'localhost'
@LindnerBrewery
LindnerBrewery / profile.ps1
Last active October 2, 2023 10:26
PsProfile
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"version": 2,
"final_space": true,
"console_title_template": "{{if .Root}}root {{end}}{{ .Shell }} in {{ .Folder }}",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
@LindnerBrewery
LindnerBrewery / my.omp.json
Last active October 2, 2023 10:04
Oh-My-Posh
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"version": 2,
"final_space": true,
"console_title_template": "{{if .Root}}root {{end}}{{ .Shell }} in {{ .Folder }}",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
@LindnerBrewery
LindnerBrewery / Test-DynamicParameters.ps1
Created July 18, 2022 12:49
Test-DynamicParameters
function Test-DynamicParameters {
# CmdletBinding is mandatory for using dynamic parameters
[CmdletBinding(DefaultParameterSetName = "default")]
param (
# One DynamicParam will only be usable if $name contains at least 2 elements
[Parameter(mandatory = $false)]
[ValidateNotNullOrEmpty()]
[String[]]
$Name
#stop service
Stop-Service 'OctopusDeploy Tentacle:*' -ErrorAction Continue
# download tentacle
$tentacle = "$Env:TEMP\tentacle.msi"
Invoke-WebRequest -UseBasicParsing -Uri https://download.octopusdeploy.com/octopus/Octopus.Tentacle.6.0.0-x64.msi -OutFile $tentacle
# install/update tentacle
Start-Process msiexec.exe -ArgumentList "/i $tentacle /qb" -Wait