'PowerShell $Script:info["VARIABLE"] > Cannot index into a null array
I'm getting errors saving credentials to cache, this doesn't seem to work while $response is valid and tokens have been received.
Does anybody know how this $Script: part is supposed to work? I can't find anything about it..
$Script:refresh_tokens["$ClientId-$Resource"] = $response.refresh_token
Cannot index into a null array. At C:\Program Files\WindowsPowerShell\Modules\AADInternals\0.6.6\AccessToken.ps1:1601 char:13 $Script:tokens["$ClientId-$Resource"] = $response ... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CategoryInfo : InvalidOperation: (:) [], RuntimeException FullyQualifiedErrorId : NullArray
$Script:refresh_tokens["$ClientId-$Resource"] = $response.refresh_token
Cannot index into a null array. At C:\Program Files\WindowsPowerShell\Modules\AADInternals\0.6.6\AccessToken.ps1:1601 char:13 $Script:tokens["$ClientId-$Resource"] = $response ... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : NullArray
https://github.com/Gerenios/AADInternals/blob/master/AccessToken_utils.ps1
Solution 1:[1]
$script: is a scope modifier - it's telling PowerShell "this variable was defined in a parent scope, but I want to update it from here". BUT, inside a module-bound command, script-scope is the same as module-scope, so those references only work when you've imported the containing module, it might not work as expected when you extract the function definitions from the module. – Mathias R. Jessen
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | H1dden69 |
