Skip to content

Instantly share code, notes, and snippets.

View mwallner's full-sized avatar
🧙

Manfred Wallner mwallner

🧙
View GitHub Profile
@mwallner
mwallner / GroovyScriptRunner.groovy
Last active October 11, 2024 05:47
A Groovy Script that uses groovy.lang.Binding to pass arbitrary (named) paramters to another Groovy Script
/* groovylint-disable JavaIoPackageAccess, SystemExit, VariableTypeRequired */
if (args.length < 1) {
println 'Please provide either the script file path or the script content as a string.'
System.exit(1)
}
// Check if input is a file path or script content
def scriptInput = args[0]
def scriptFile = new File(scriptInput)
@mwallner
mwallner / Invoke-FixPSModulePathForPowerShellDesktopWhenIndirectlyCalledFromPwsh.ps1
Created July 4, 2024 06:07
Fixup PSModulePath in PowerShell Desktop when called indirectly called from pwsh
#region fix PSModulePath in PowerShell Desktop when indirectly called from pwsh
function Invoke-FixPSModulePathForPowerShellDesktopWhenIndirectlyCalledFromPwsh {
if (($env:PSModulePath -split ';') -contains "${env:ProgramFiles}\PowerShell\Modules") {
# need to rip out the good bits for pwsh -> something -> powershell call chain
# chocolateyInstall\helpers\functions\Get-EnvironmentVariable.ps1
function Get-EnvironmentVariable {
<#
.SYNOPSIS
<#
.SYNOPSIS
BoxStarter script to configure Windows 10 development PC.
.DESCRIPTION
You might need to set:
Set-ExecutionPolicy RemoteSigned
Set-ExecutionPolicy Unrestricted
Set-ExecutionPolicy Bypass
@mwallner
mwallner / chronotags.ps1
Created March 15, 2023 09:39
chronologically sort git tags by commit-date
git tag -l --format="%(refname) :: %(if)%(committerdate:iso)%(then)%(committerdate:iso)%(else)%(*committerdate:iso)%(end)" | % {($r,[datetime]$t)=$_.Split("::"); @{r=$r;t=$t}} | Sort t | Select r
@mwallner
mwallner / setup-vm-winhost.ps1
Created June 13, 2022 21:12
WIndows VM Base pwsh and SSH Remoting
choco install pwsh -y
choco install ripgrep -y
choco install vscode -y
Get-WindowsCapability -Online | Where-Object {$_.Name -like 'OpenSSH*'} | Add-WindowsCapability -Online
Start-Service sshd
Set-Service sshd -StartupType Automatic
Stop-Service sshd
@mwallner
mwallner / boxstarter_host_setup.ps1
Last active July 30, 2023 19:14
psconfeu23_hostsetup
# NuGet package provider. Do this early as reboots are required
if (-not (Get-PackageProvider -Name NuGet -ErrorAction SilentlyContinue)) {
Write-Host "Install-PackageProvider"
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Scope AllUsers -Confirm:$False
# Exit equivalent
Invoke-Reboot
}
@mwallner
mwallner / Test-ChocoTransitiveDependencyChain.ps1
Created April 20, 2022 06:34
simple script to check if a given choco package and all transitive dependencies are installed
[cmdletbinding()]
param(
$packageName
)
$ErrorActionPreference = 'Stop'
function Test-TransitiveDependencies {
[cmdletbinding()]
param($allPackages, $pkgID)
@mwallner
mwallner / Get-UglyButShortUniqueDirname.ps1
Last active May 14, 2022 02:53
create a unique directory name based of system.guid
function Get-UglyButShortUniqueDirname {
[CmdletBinding()]
param (
)
$t = "$([System.Guid]::NewGuid())".Replace("-", "")
Write-Verbose "base guid: $t"
$t = "$(0..$t.Length | % { if (($_ -lt $t.Length) -and !($_%2)) { [char][byte]"0x$($t[$_])$($t[$_+1])" } })".replace(" ", "").Trim()
wget https://download.foldingathome.org/releases/public/release/fahclient/debian-testing-64bit/v7.4/fahclient_7.4.4_amd64.deb
wget https://download.foldingathome.org/releases/public/release/fahcontrol/debian-testing-64bit/v7.4/fahcontrol_7.4.4-1_all.deb
wget https://download.foldingathome.org/releases/public/release/fahviewer/debian-testing-64bit/v7.4/fahviewer_7.4.4_amd64.deb
sudo dpkg -i --force-depends fahclient_7.4.4_amd64.deb
sudo dpkg -i --force-depends fahcontrol_7.4.4-1_all.deb
sudo dpkg -i --force-depends fahviewer_7.4.4_amd64.deb
@mwallner
mwallner / Add-TrustedHostDownloadSite.ps1
Created February 11, 2020 16:39
when using a offline VisualStudio layout, you need to ensure the host you're downloading from is "trusted"
function Add-TrustedHostDownloadSite {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string]$ServerName,
[Parameter(Mandatory = $false)]
[string]$Domain = "myorg.somedomain"
)
Push-Location