public/Import/Import-GroupISETheme.ps1
function Import-GroupISETheme { <# .SYNOPSIS Imports all PowerShell ISE theme files from a specified directory. .DESCRIPTION The Import-GroupISETheme function scans the given directory (recursively) for any `.ps1xml` theme files and imports them into the ISE color theme registry using Import-ISEThemeFile. This is typically used to batch-import themes and is often called by higher-level functions like Add-ISEThemeMenu. .PARAMETER Directory The path to a folder containing one or more `.ps1xml` ISE theme files. .EXAMPLE Import-GroupISETheme -Directory 'C:\ISEThemes\' Imports all .ps1xml theme files from the specified directory into the registry. .NOTES Author: Jeff Pollock GitHub: https://github.com/phriendx/ISEColorTheme.cmdlets Website: https://pxlabs.info #> [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string]$Directory ) if (-not (Test-Path -Path $Directory -PathType Container)) { throw "The specified directory '$Directory' does not exist or is not accessible." } $themeRegistryPath = 'HKCU:\Software\Microsoft\PowerShell\3\Hosts\PowerShellISE\ColorThemes' if (-not (Test-Path $themeRegistryPath)) { New-Item -Path (Split-Path $themeRegistryPath) -Name 'ColorThemes' -Force | Out-Null } Get-ChildItem -Path $Directory -Filter *.ps1xml -Recurse | ForEach-Object { Import-ISEThemeFile -Path $_.FullName } } |