How pass variable to a page?

Got two pages in the app.
One computer and one user.
When search in the userpage.ps1 you get a computer name.
I want to click on that and then the link should be something like:

And then when entering computer.ps1 I want populate the $ComputerName variable on that page with the “nameididclickon”

Any good idea?

I solved it.

So, if you enter like https://FQDN/devce?DeviceName=xxx then you can do something like this at the page.

    if ($Headers["Referer"] -like "*?DeviceName=*") {
        $DeviceName = $Headers["Referer"].Split("=")[1]
        $DeviceName = $DeviceName.Trim()

:wave: Hi,

As with most things, there’s always more than one way to achieve the same outcome.

The built-in way of doing this, since version 4.0.10, is by accessing the $Query variable. This is a dictionary of the variables passed via the url query string. It’s already there and parsed for you - saving you the work.

So in your example Url: https://FQDN/devce?DeviceName=xxx

You can access the value of DeviceName using $Query['DeviceName'].

Hope that helps!

1 Like

This is even better, thanks!