Benutzer-Werkzeuge

Webseiten-Werkzeuge


powershell:scriptinscript

Script in Script ausführen

test-helloworld.ps1:

[CmdletBinding()]
param
(
    [Parameter(Mandatory=$True)][String]$MyPar
)
 
Write-Host "Hallo $MyPar!"

test-runscript.ps1:

param()
 
$zzz = @{MyPar="Blubb"}
 
$File = $Path + "test-helloworld.ps1"
$ScriptFileData = Get-Content $File
$ScriptData = @('param($zzz) &{')
$ScriptData += $ScriptFileData
$ScriptData += '} @zzz'
 
$Script = [Scriptblock]::Create($ScriptData)
 
Invoke-Command -ScriptBlock $Script -ArgumentList $zzz

Quelle: Link, Link, Splatting

powershell/scriptinscript.txt · Zuletzt geändert: 2018/01/02 17:31 von ronny

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki