Specify Environment (Powershell Version) for Subpages in a Dashboard?

Hi all!

Is it possible to somehow override the Environment Settings for a Subpage in a dashboard?

Usecase:

  • My baseline should be Powershell 7.x

  • I do have a Subpage as part of my dashboard that still requires .NET 4.x and Windows Powershell (5.1) (Citrix XenServer Powershell from the official SDK)

  • Obviously only because of that I don’t want to run my whole dashboard in “compatibility mode”…

I tried a couple things already but didn’t have success so far. :frowning:

Any help is really much appreciated.

Thanks,
Don

Product: PowerShell Universal
Version: 3.4.1

What have you tried?

Really, you don’t NEED the page to run in Powershell 5.1, you just need the commands to run in 5.1…

I’m not sure what all you are doing, but this is literally a line taken from one of my dashboards running on PS7…

$newPwd = Invoke-Command -ScriptBlock { Powershell.exe -Command "Add-Type -AssemblyName 'System.Web' ; [System.Web.Security.Membership]::GeneratePassword(13,1)" }

All because PS7 doesn’t support System.Web anymore ;).

So, you may be able to do something similar. Obviously, it has its limitations and returning variables will be more difficult.

Alternative would be to create another dashboard entirely, set the URL for the dashboard as the full URL of the page that needs to run in 5.1 and move that page to this other dashboard. Navigation wouldn’t change this way, and you would be running native 5.1.

Hey Jori

Sorry for the delayed answer. Unfortunately I’m very busy with some other issues @work and didn’t have time to verifiy your proposed solution.
However let me tell you that both of them are very smart! :ok_hand::smile:
I think that I will try your second suggestion because the Invoke-Command variant is probably an “overkill” since I need some specific Citrix dlls to be loaded.
Going with a dedicated “pseudo Dashboard” which only presents this subpage however looks like a potential solution / workaround to the problem.

As soon as I can try it (maybe tomorrow or monday) I will report about the results. :slight_smile:

Best regards and thanks again,
Don

Dear Jori

Sorry it took really long for me to come back with a feedback here.
Just wanted to update you and say that your intended solution of “nesting” the relevant POSH 5.1 Site into a PWSH 7.x Dashboard does not really work 100% seamless.
The reason is that we’re using a Navigation as well and basically I’d need to maintain that main Dashboard section twice and to be honest it would really be just a workaround.

Your first method though is something that I think @adam will decativeate / avoid soon based on the issue he opened here:

Probably the best and cleanest way would be to be able to override / specify the wished environment on a per subpage setting rather then on a Dashboard basis only… Like we can do for the Scripts, where you also can specify the desired Environment in the Edit Settings of the Script:
image

Best regards,
Don

Hi Don,

This is true about nesting the dashboard, you would have to find a clever way to make it more seemless (perhaps maintaining the navigation in a single file?)

For the second, that doesn’t affect it. That is about Powershell 7 trying to load Windows Powershell modules in compatibility mode. Doing an Invoke-Command is actually starting a seperate Windows Powershell instance, running a command, and returning the result.

The idea of having different subpages on different environments is basically the same as the workaround of having an entire new dashboard. They would be running in separate processes with their own sets of variables.

Hi Jori

OK thanks for the clarification about the mentioned issue on github.

Regarding the idea of having subpages specifically configured for a particular Environment, I think this would resolve all the problems, also the need of having to create an entire new Dashboard with its dependencies and complexity and so avoid potential issues. As you mentioned it would anyway start a new process on its own and therefore resolve all caveats I think… Additionally it would be really “seamless”. no need to do some “hacky stuff” to workaround some 3rd party limitations…

Let’s see what Adam will think of that…

Best,
Don