AveYo / LeanAndMean

snippets for power users
MIT License
239 stars 37 forks source link

Bat2Ps hybrid w/ Params support #4

Closed couleurm closed 1 year ago

couleurm commented 1 year ago

Hey, made a cool hybrid and thought about you, it's got some aspects still rusty, feel free to have fun with it 👍

<# : @couleurm on github
@echo off & set a=%* &REM to join multiple strings as arrays
::set a=%a:" "=","%
set a=%a:"=\^"%
PowerShell "& (& {[Scriptblock]::Create((Get-Content \"%~f0\" -Raw))}) %a%" & exit /b
#>
param(
    $argument,
    [Parameter(ValueFromRemainingArguments = $true)]
    [System.Collections.Arraylist]
    $rest
    )
"argument"
$argument
"rest"
$rest
AveYo commented 1 year ago

It's well known. But I stay away from the explicit Scriptblock because it floods the Powershell event log, each time quoting the whole script.