Receive Error "InvalidOperation: Index operation failed; the array index evaluated to null." on Import-Module
Whenever I run Import-Module Terminal-Icons I receive the following array index related error message:
InvalidOperation: Index operation failed; the array index evaluated to null.
Currently I have Import-Module Terminal-Icons in my $PROFILE so this message appears whenever I start a PowerShell session.
Here is a screenshot of the error in a -NoProfile session:

Expected Behavior
Expect that Import-Module would import the module cleanly without any issues.
Current Behavior
Receive error message when importing the module: InvalidOperation: Index operation failed; the array index evaluated to null.
Possible Solution
Not sure here, I looked into the source code and believe it would have something to do with module's themes data (colorThemes, iconThemes, glyphs), but just guessing here.
Steps to Reproduce (for bugs)
- Start PowerShell Core
- Run command
Import-Module Terminal-Icons
Context
Not a huge impact other than the error message, but could be more fundamental issues downstream.
Your Environment
- Module version used:
0.9.0 - Operating System and PowerShell version:
- PowerShell Stable Version:
7.2.4 - PowerShell Preview Version:
7.3.0-preview.4 - OS: Microsoft Windows 11 Pro Insider Preview - Version 10.0.25126 Build 25126
- PowerShell Stable Version:
Tested on both PowerShell Core Preview and PowerShell Core Stable:


Any help is appreciated and thanks for the great module!
@jimbrig Can you run Import-Module Terminal-Icons -Force, then run $Error[0].ScriptStackTrace when you get this error? That should tell you the file and line number where this is happening and be easier to track this down.
@jimbrig Can you run
Import-Module Terminal-Icons -Force, then run$Error[0].ScriptStackTracewhen you get this error? That should tell you the file and line number where this is happening and be easier to track this down.
Sure thing. Great debugging tip for the future also, much appreciated. I'll get back to you this evening.
I'm getting a similar error message although it isn't consistent. I can open the terminal without any problems one time, then get an error the next (and vice versa). I don't know if it is a factor but my powershell configuration is set to open two sessions in a split window simultaneously.
Import-Clixml: Value for dictionary entry is not specified. Line 227, position 39.
InvalidOperation: Index operation failed; the array index evaluated to null.
Import-Clixml: The '=' character, hexadecimal value 0x3D, cannot be included in a name. Line 818, position 22.
InvalidOperation: Index operation failed; the array index evaluated to null.
InvalidOperation: Index operation failed; the array index evaluated to null.
Per @jimbrig 's suggestion, I added the -Force parameter and then ran $Error[0].ScriptStackTrace giving this stack trace:
at <ScriptBlock>, D:\Documents\PowerShell\Modules\Terminal-Icons\0.9.0\Terminal-Icons.psm1: line 1183
at <ScriptBlock>, D:\Documents\PowerShell\Modules\Terminal-Icons\0.9.0\Terminal-Icons.psm1: line 1180
at <ScriptBlock>, D:\Documents\PowerShell\Microsoft.PowerShell_profile.ps1: line 190
at <ScriptBlock>, <No file>: line 1
Let me know if there is anything I can do to help.
@Niwotian60 @jimbrig There seems to be some corruption in the theme XML files that Terminal-Icons saves to your user directory. Try deleting these files, them running Import-Module Terminal-Icons -Force again:
Mac / Linux:
~/.local/share/powershell/Community/Terminal-Icons/devblackops_color.xml
~/.local/share/powershell/Community/Terminal-Icons/devblackops_icon.xml
Windows:
$env:APPDATA/powershell/Community/Terminal-Icons/devblackops_color.xml
$env:APPDATA/powershell/Community/Terminal-Icons/devblackops_icon.xml
@devblackops Thank you for responding (and for the utility!)
UPDATE
I forgot that I had terminals open inside vscode that I hadn't closed. I closed everything, deleted the xml files again, rebooted, and everything seems to be working so far. I'll add a new comment if the problem reappears. Thanks again!
END UPDATE
I tried this before my initial report and I also tried a complete uninstall/reinstall, but I gave it another shot. The first terminal tab I launched had no problem, the second time I got the following error in one of the two shells that spawned:
Import-Clixml: N attribute was expected. Line 747, position 19.
InvalidOperation: Index operation failed; the array index evaluated to null.
InvalidOperation: Index operation failed; the array index evaluated to null.
Running the stacktrace gave:
$Error[0].ScriptStackTrace
at <ScriptBlock>, D:\Documents\PowerShell\Modules\Terminal-Icons\0.9.0\Terminal-Icons.psm1: line 1183
at <ScriptBlock>, D:\Documents\PowerShell\Modules\Terminal-Icons\0.9.0\Terminal-Icons.psm1: line 1180
at <ScriptBlock>, D:\Documents\PowerShell\Microsoft.PowerShell_profile.ps1: line 190
at <ScriptBlock>, <No file>: line 1
And while I doubt it matters, the location on my Windows 11 machine is:
$env:AppData\Roaming\powershell\Community\Terminal-Icons
And the problem still exists. Here is the latest screen dump after the latest Windows Terminal Preview update and a system reboot:
PowerShell 7.2.5
Copyright (c) Microsoft Corporation.
https://aka.ms/powershell
Type 'help' to get help.
Import-Clixml: The 'S' start tag on line 108 position 28 does not match the end tag of 'Sml'. Line 108, position 45.
InvalidOperation: Index operation failed; the array index evaluated to null.
InvalidOperation: Index operation failed; the array index evaluated to null.
Loading personal and system profiles took 813ms.
> $Error[0].ScriptStackTrace
at <ScriptBlock>, D:\Documents\PowerShell\Modules\Terminal-Icons\0.9.0\Terminal-Icons.psm1: line 1183
at <ScriptBlock>, D:\Documents\PowerShell\Modules\Terminal-Icons\0.9.0\Terminal-Icons.psm1: line 1180
at <ScriptBlock>, D:\Documents\PowerShell\Microsoft.PowerShell_profile.ps1: line 190
at <ScriptBlock>, <No file>: line 1
>
I did a quick grep on Sml in .xml files and the code in the terminal-icons/0.9.0 subdirectories and didn't get any matches.
@Niwotian60 @jimbrig There seems to be some corruption in the theme XML files that Terminal-Icons saves to your user directory. Try deleting these files, them running
Import-Module Terminal-Icons -Forceagain:Mac / Linux:
~/.local/share/powershell/Community/Terminal-Icons/devblackops_color.xml ~/.local/share/powershell/Community/Terminal-Icons/devblackops_icon.xmlWindows:
$env:APPDATA/powershell/Community/Terminal-Icons/devblackops_color.xml $env:APPDATA/powershell/Community/Terminal-Icons/devblackops_icon.xml
I had the problem that the icons were not showing up in the terminal also the console showed me the following error:
Save-Preferences: cannot bind argument to parameter 'preferences' because it is null.
And yes, this solution helped me. Thank you.
thanks everyone - the problem is fixed on my end and if everyone is satisfied i don't see why this issue needs to remain open anymore. Great feedback as always from the PowerShell community! 💪
@Niwotian60 @jimbrig There seems to be some corruption in the theme XML files that Terminal-Icons saves to your user directory. Try deleting these files, them running
Import-Module Terminal-Icons -Forceagain: Mac / Linux:~/.local/share/powershell/Community/Terminal-Icons/devblackops_color.xml ~/.local/share/powershell/Community/Terminal-Icons/devblackops_icon.xmlWindows:
$env:APPDATA/powershell/Community/Terminal-Icons/devblackops_color.xml $env:APPDATA/powershell/Community/Terminal-Icons/devblackops_icon.xmlI had the problem that the icons were not showing up in the terminal also the console showed me the following error:
Save-Preferences: cannot bind argument to parameter 'preferences' because it is null.And yes, this solution helped me. Thank you.
Thanks Man, Worked For Me!
Thanks worked for me after deleting the files, then re-installing the module. (already reinstalled it tons of times before but deleting these files somehow made the next redownload work)