Pages as different files issue

Hi everyone,

I am trying to make a clean setup for the seperate ud pages which my dashboard has but when i try to load them into a a $pages variable with this:
$Pages = Get-ChildItem (Join-Path PSScriptRoot 'pages') -Recurse -File | ForEach-Object { & _.FullName
}

and even though the pages are loaded, and in ise i can see them being loaded into the variables, when i start the dashboard after having the pages set up like this
$Dashbard = New-UDDashboard -Title “page bla bla bla” -Pages $Pages -Theme $Theme_Azure -LoginPage $LoginPage -Footer $footer
it just gives the error:

New-UDDashboard : Cannot bind argument to parameter ‘Pages’ because it is null.

Anything obvious i missed?

Shouldn’t &.Fullname be $.Fullname?

Either way, this i my implementation:

 $Pages = @()

Get-ChildItem (Join-Path $PSScriptRoot "pages")  | ForEach-Object {
    $Pages += . $_.FullName
}
1 Like

This is what I have been using

$PageFolder = Get-ChildItem (Join-Path $PSScriptRoot pages)
$Pages = Foreach ($Page in $PageFolder){
    . (Join-Path $PSScriptRoot "pages\$Page")
}

I have the code as shown by Adam earlier, but if you just try to run the file as a script from ISE it will not work.

You would then have to “dot source” the PowerShell file for it to work.

This works when I import it through a module and not when I try to just run a script from ISE.

$Pages = Get-ChildItem (Join-Path $PSScriptRoot 'pages') -Recurse -File  |
ForEach-Object {
    Write-Verbose "loading: $($_.FullName)"
    & $_.FullName
}

Probably a ‘feature’ of ISE.
I have moved from using ISE to using Visual Studio Code for developing dashboards, so probably why i have not encountered the issue

I use IIS, the code snippet from me works flawlessly.
I simply have a folder called pages in my site directory with all individual pages in.

C:\inetpub<Project>\pages

Thank you all for the help.
I’m all set :slight_smile: