This commit is contained in:
1 parent
cdfa0ecda8
commit
4dfec83063
15 files changed
+63
-39
No files matched your search
@@ -2,6 +2,19 @@ Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference='Stop'
|
||||
Import-Module (Join-Path $PSScriptRoot 'MsPrivate.IO.psm1') -ErrorAction Stop
|
||||
|
||||
function New-MsPrivateScriptInvoker {
|
||||
param([Parameter(Mandatory)][string]$Root)
|
||||
$runtimeRoot=[IO.Path]::GetFullPath($Root).TrimEnd([IO.Path]::DirectorySeparatorChar)+[IO.Path]::DirectorySeparatorChar
|
||||
if(-not[IO.Directory]::Exists($runtimeRoot)){throw "Runtime root does not exist: $runtimeRoot"}
|
||||
{
|
||||
param([Parameter(Mandatory)][string]$Script,[hashtable]$Parameters=@{})
|
||||
if($Script-notmatch'^[A-Za-z0-9][A-Za-z0-9.-]*\.ps1$'){throw "Invalid runtime script name: $Script"}
|
||||
$path=[IO.Path]::GetFullPath((Join-Path $runtimeRoot $Script))
|
||||
if(-not$path.StartsWith($runtimeRoot,[StringComparison]::OrdinalIgnoreCase)-or-not[IO.File]::Exists($path)){throw "Runtime script was not found: $Script"}
|
||||
& $path @Parameters|Out-Host
|
||||
}.GetNewClosure()
|
||||
}
|
||||
|
||||
function Invoke-MsPrivateGroupPlan {
|
||||
param(
|
||||
[Parameter(Mandatory)][object[]]$Groups,
|
||||
@@ -36,4 +49,4 @@ function Invoke-MsPrivateGroupPlan {
|
||||
$report
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function Invoke-MsPrivateGroupPlan
|
||||
Export-ModuleMember -Function Invoke-MsPrivateGroupPlan,New-MsPrivateScriptInvoker
|
||||
Reference in new issue
Block a user