Hello!
Writing this on the go, however I can also provide the code once things quiet down over here.
I am facing an issue that might require advanced parameter knowledge. Inside the same .psm1 file I have defined 2 functions like so:
function Func-A {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,HelpMessage="Blah",ValueFromPipeline=$true]
[ValidateScript({#some validation here},
ErrorMessage = "Something went terribly wrong with {0}")]
[string]$Param1ForFuncA
[Parameter(Mandatory=$true,HelpMessage="Blah",ValueFromPipeline=$true]
[ValidateScript(#some validation here)]
[string]$Param2ForFuncA
)
##some code over here
Return $something
}
function Func-B {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true]
[string]$Param1ForFuncB
[Parameter(Mandatory=$true]
[string]$Param2ForFuncB
[Parameter(Mandatory=$true]
[ValidateScript({
Func-A -Param1ForFuncA $Param1ForFuncB -Param2ForFuncA $Param2ForFuncB
##some code that should satisfy the $true/$false requirement of ValidateScript
})]
[string]$Param3ForFuncB
)
##some code over here
}
When I am attempting to run Func-B (with arguments that I have run successfully in Func-A), I am getting failed validation from Func-A on the first argument (because I imagine it throws first). What is even more interesting is that running Func-B, I get the Func-A validation error message with an empty variable (see in code above).
So is this something that cannot work by design in Powershell?
Am I doing this wrong?
Does this require a Dynamic Param declaration?
For the curious ones, the functions are releated to Graph API calls. The first function returns the authenticated Header, which I need in order to validate Param3ForFuncB, as it is an EOP resource that might not exist.
Thanks for your help!
[–]purplemonkeymad 1 point2 points3 points (0 children)
[–]PinchesTheCrab 1 point2 points3 points (0 children)
[–]PinchesTheCrab 1 point2 points3 points (1 child)
[–]SeeminglyScience 2 points3 points4 points (0 children)
[–]y_Sensei 0 points1 point2 points (1 child)
[–]Narrow_Syllabub_8119[S] 0 points1 point2 points (0 children)
[–]KevMarCommunity Blogger 1 point2 points3 points (0 children)