I am creating a wrapper and in my ps1 file I want to invoke:
ConnectTo-PSSession -Path "test" -Confirm
Since I want to wrap this call I've created a ps1 file with those same params:
Param(
[string]$Path,
[switch]Confirm
)
Now I would like to call the ConnectTo-PSSession with those parameters but the main problem is that I dont want to even call the flag if its not required:
ConnectTo-PSSession -Path $Path $Confirm //Confirm here is not working
I took a look at Invoke-Expression but it seems like it will have security issues. Is there a way for me to achieve my result without Invoke-Expression? I can of course start writing If statements but this does not scale well with multiple parameters since I will need a insane amount of those checks.