KelvinTegelaar / PowerShellWarrantyReports

a repo dedicated to automatic warranty reporting and retrieval from different systems such as IT-Glue, Connectwise, Autotask, and N-central.
GNU Affero General Public License v3.0
173 stars 71 forks source link

Module broken on powershell core linux #67

Closed trackd closed 7 months ago

trackd commented 1 year ago

Hello,

Looks like this module wont work on Powershell Core on Linux.

PS /home/username> $PSVersionTable

Name Value


PSVersion 7.3.2 PSEdition Core GitCommitId 7.3.2 OS Linux 5.15.0-58-generic #64-Ubuntu SMP Thu Jan 5 11:43:13 UTC 2023 Platform Unix PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0

PS /home/username> Install-Module -Name PSWarranty -Scope CurrentUser

PS /home/username> Import-module PSWarranty -Verbose VERBOSE: Loading module from path '/home/username/.local/share/powershell/Modules/PSWarranty/1.8.0/PSWarranty.psd1'. VERBOSE: Populating RepositorySourceLocation property for module PSWarranty. VERBOSE: Loading module from path '/home/username/.local/share/powershell/Modules/PSWarranty/1.8.0/PSWarranty.psm1'. VERBOSE: Exporting function 'get-AppleWarranty'. VERBOSE: Exporting function 'get-DellWarranty'. VERBOSE: Exporting function 'get-HPWarranty'. VERBOSE: Exporting function 'get-LenovoWarranty'. VERBOSE: Exporting function 'Get-MSWarranty'. VERBOSE: Exporting function 'get-ToshibaWarranty'. VERBOSE: Exporting function 'Get-WarrantyAutotask'. VERBOSE: Exporting function 'Get-WarrantyBTIO'. VERBOSE: Exporting function 'Get-WarrantyCSV'. VERBOSE: Exporting function 'Get-WarrantyCWM'. VERBOSE: Exporting function 'Get-WarrantyDattoRMM'. VERBOSE: Exporting function 'Get-WarrantyHalo'. VERBOSE: Exporting function 'Get-WarrantyHudu'. VERBOSE: Exporting function 'Get-WarrantyITG'. VERBOSE: Exporting function 'Get-WarrantyNable'. VERBOSE: Exporting function 'Get-WarrantyNinja'. PS /home/username> Get-Command -Module PSWarranty PS /home/username>

I've tried on a different machine as well with same results.

Think it's something with the file paths, manually dot sourcing files works.

trackd commented 1 year ago

after a little more testing i found Get-ChildItem: Cannot find path '/home/username/.local/share/powershell/Modules/PSWarranty/1.8.0/Public' because it does not exist.

PSWarranty.psm1 $Functions = @(Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue) + @(Get-ChildItem -Path $PSScriptRoot\private\*.ps1 -ErrorAction SilentlyContinue)

needs to be changed to lowercase 'public' as linux is case-sensitive.

also i would probably skip the '-ErrorAction SilentlyContinue' on Get-ChildItem.. better it throws an error so we can quickly see that.

changing it to lowercase public fixes the issue.