Ich habe eine Reihe von Funktionen, die innerhalb und außerhalb eines Workflows in einem Powershell-Skript aufgerufen werden müssen, das einen Workflow zum Verwalten von Remotecomputern verwendet. Ich habe versucht, ein Modul zum Inline passieren, aber die Methode unter dem Inline-Skript kann nicht die dynamischen Module „SharedFunctions“ findenAufruf von Funktionen in Workflows in Powershell 4.0
#Script Only Functions
function funct1 {}
function funct2 {}
#Script and Workflow Functions
New-Module SharedFunctions {
function sharedFunct1 {}
function sharedFunct2 {}
} -Name SharedFunctions | Import-Module
#Workflow
workflow w1 {
Param([string[]] $computerList)
foreach -parallel($computer in $computerList){
#Shared Function out of Inline Script
sharedFunct1
InlineScript{
#Shared Function inside InlineScript
sharedFunct2
#Do stuff
} -PSRequiredModules "SharedFunctions"
}
}
<# Local Script #>
funct1
sharedFunct1
w1
ich die Fehlermeldung
The specified module 'SharedFunctions' was not loaded because no valid module file was found in any module directory.
+ CategoryInfo : ResourceUnavailable: (FunctionModule:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
+ PSComputerName : [localhost]
ich, dass Module lesen kann in Workflows importiert werden. Ist das mit Dynamic Modules nicht möglich? Wie kann ich gemeinsame Funktionen innerhalb des Workflows aufrufen? sharedFunct1
kann eine Aufgabe sein, z. B. das Aktualisieren einer Protokolldatei auf dem Hostcomputer mit Updates von jedem Thread, der auf Remotecomputern ausgeführt wird.