epacke / BigIPReport

Overview of your loadbalancer configuration
https://loadbalancing.se
8 stars 2 forks source link

Underlay path not found #188

Closed jo-xxx closed 4 years ago

jo-xxx commented 4 years ago

| Copy-Item -Recurse -Force -Path 'underlay/*' -Destination … | ~~~~~~~~~~~~~ | Cannot find path 'C:\Users\myuser\underlay' because it does not exist.

I'm not sure how the file structure is supposed to look like. My setup is -- C:\Users\myuser\Documents\bigipreport\ ---- bigipreport-5.4.2.ps1 ---- bigipreportconfig.xml ---- underlay\ ------ ****

-- C:\inetpub\wwwroot\ ---- default.htm ---- css\ ---- images\ ---- js\ ---- json\

if ('underlay/' -ne $Global:bigipreportconfig.Settings.ReportRoot) { fails because PowerShell searches path %userprofile%/underlay/.

This worked for me but may not work for everyone:

if ('underlay/' -ne $Global:bigipreportconfig.Settings.ReportRoot) {
    log verbose "Copying underlay/* to $($Global:Bigipreportconfig.Settings.ReportRoot)"
    Copy-Item -Recurse -Force -Path "$($PSScriptRoot)/underlay/*" -Destination $Global:Bigipreportconfig.Settings.ReportRoot
}
timriker commented 4 years ago

In the start of the script I'm now changing the working directory to the script location. Does this work?

What is your ReportRoot set to? Can you try a relative path? ../../../../inetpub/wwwroot as well? Either should work.

jo-xxx commented 4 years ago

My ReportRoot is set as: <ReportRoot>C:/inetpub/wwwroot/</ReportRoot> and it works fine now: {"severity":"VERBOSE","datetime":"2020-09-24 11:24:56","message":"Copying underlay/* to C:/inetpub/wwwroot/"}

I tried the relative path <ReportRoot>../../../../inetpub/wwwroot</ReportRoot> and it gives me {"severity":"ERROR","datetime":"2020-09-24 11:17:05","message":"Can't access the site root ../../../../inetpub/wwwroot/"}

I tried Copy-Item -Recurse -Force -Path 'underlay/*' -Destination '../../../../inetpub/wwwroot/' and it works: {"severity":"VERBOSE","datetime":"2020-09-24 11:24:56","message":"Copying underlay/* to C:/inetpub/wwwroot/"}

jo-xxx commented 4 years ago

I'm running PS version 7.0.3 and OS Windows Server 2016

timriker commented 4 years ago

I noticed I was recopying in each spawned process. I fixed that.

I'm running in production in C:\Users\<username>\BigIPReport.timriker\ with:

<ReportRoot>../../../inetpub/wwwroot/</ReportRoot>

and that's working for me both in windows powershell and in Ubuntu/WSL1 pwsh

jo-xxx commented 4 years ago

Oh, yes, it works for me too when I add a couple of "../". And it's only copied once now.