Rufen Sie das Skript aus einer Batchdatei (*.bat) oder CMD auf
_PowerShell Core_
pwsh.exe -NoLogo -ExecutionPolicy Bypass -Command "./Script.ps1 -Param1 Hallo -Param2 Welt"
pwsh.exe -NoLogo -ExecutionPolicy Bypass -Command "pfad-zum-skript/Script.ps1 -Param1 Hallo -Param2 Welt"
pwsh.exe -NoLogo -ExecutionPolicy Bypass -Command "./Script.ps1 Hallo -Param2 Welt"
pwsh.exe -NoLogo -ExecutionPolicy Bypass -Command "./Script.ps1 Hallo Welt"
pwsh.exe -NoLogo -ExecutionPolicy Bypass -Command "./Script.ps1 -Param2 Welt Hallo"
PowerShell
powershell.exe -NoLogo -ExecutionPolicy Bypass -Command "./Script.ps1 -Param1 Hallo -Param2 Welt"
powershell.exe -NoLogo -ExecutionPolicy Bypass -Command "pfad-zum-skript/Script.ps1 -Param1 Hallo -Param2 Welt"
powershell.exe -NoLogo -ExecutionPolicy Bypass -Command "./Script.ps1 Hallo -Param2 Welt"
powershell.exe -NoLogo -ExecutionPolicy Bypass -Command "./Script.ps1 Hallo Welt"
powershell.exe -NoLogo -ExecutionPolicy Bypass -Command "./Script.ps1 -Param2 Welt Hallo"
Rufen Sie von PowerShell aus auf
PowerShell Core oder Windows PowerShell
& pfad-zum-skript/Script.ps1 -Param1 Hallo -Param2 Welt
& ./Script.ps1 -Param1 Hallo -Param2 Welt
Script.ps1 - Skriptcode
param(
[Parameter(Mandatory=$True, Position=0, ValueFromPipeline=$false)]
[System.String]
$Param1,
[Parameter(Mandatory=$True, Position=1, ValueFromPipeline=$false)]
[System.String]
$Param2
)
Write-Host $Param1
Write-Host $Param2