mbegan / Okta-PSModule

Okta API Powershell Wrapper Module
Other
102 stars 31 forks source link

Cannot overwrite variable oktaVerbose because the variable has been optimized. #8

Open PHactotum opened 7 years ago

PHactotum commented 7 years ago

I do not get this everytime, but I can't seem to figure out why I do get it sometimes.

In a script that includes import-module okta, I sometimes get the following error: `Cannot overwrite variable oktaVerbose because the variable has been optimized. Try using the New-Variable or Set-Variable cmdlet (without any aliases), or dot-source the command that you are using to set the variable. At C:\Users\perry.harris\Documents\WindowsPowerShell\Modules\okta\Okta_org.ps1:3 char:1

Normally, I do not get this under PowerShell ISE, but sometimes I do. I almost always get this with PowerShell.exe. I suspect this is not an issue with your code, but it is the only set of code I've run across this with. I am running this on PS 5, under Windows 10.

Have you seen this before?

SMSAgentSoftware commented 7 years ago

I've seen this where you are casting a variable into a specific data type. In this case, you can remove the [Boolean] cast as PS should detect the boolean type anyway from the $true value.