I have a Powershell script that loads some functions that I have created from a .psm1 file. The .psm1 contains functions that should reutrn a value. All of them work fine apaprt from the example below.
The function generates a url and passes it back but it is always null even though the url is being generated correctly when debugging.
An example:
From the main script I import the .psm1 using the import-module cmdlet and call the following function ($environment variable is set):
Get-ApiUrl $environment
The function it calls is:
function Get-ApiUrl ($environment)
{
$apiUrl = "https://test$environment.example.com/api/"
return $apiUrl
}
When this runs the $apiUrl is being set correctly but when returned to the script that called the function it is blank. Does anybody understand what i'm doing wrong?
Get-ApiUrl(as in,$apiUrl = Get-ApiUrl .... - Jeroen Mostert$apiUrl = Get-ApiUrl $environmentit works. The only strange thing is that I do the same as my original post with the next function and it works perfectly. - darren25