ISEThemes.psm1

function Import-ISETheme {
    <#
    .Synopsis
    Imports PowerShell ISE themes into the Windows registry for the current user.
 
    .Description
    Imports PowerShell ISE themes into the Windows registry for the current user. This command supports verbose output for debugging purposes. Simply add on the -Verbose PowerShell common parameter.
 
    .Parameter Path
    A FileInfo object. Use Get-ChildItem to obtain a FileInfo object.
 
    .Example
 
    Get-ChildItem -Path c:\users\ArtofShell\Downloads -Recurse -Include *.ps1xml | Import-ISETheme
 
    .Notes
    This function was written by Trevor Sullivan @ Art of Shell.
    https://artofshell.com
    #>

    [CmdletBinding()]
    param (
        [Parameter(ValueFromPipeline = $true)]
        [ValidateScript({
            try {
                Test-Path -Path $PSItem.FullName -ErrorAction Stop
            }
            catch {
                throw 'Invalid path -- please try a different path'
            }
        })]
        [System.IO.FileInfo[]] $Path
    )

    process {
        if ($input) {
            $Path = $input
        }

        foreach ($Item in $Path) {
            $Theme = @{
                Path = 'HKCU:\Software\Microsoft\PowerShell\3\Hosts\PowerShellISE\ColorThemes'
                Name = $PSItem.Name.Split('.')[0]
                Value = (Get-Content -Path $PSItem.FullName -Raw)
                }
            Write-Verbose -Message ('Adding new theme: {0}, value: {1}' -f $Theme.Name, $Theme.Value)
            $null = New-ItemProperty @Theme
        }
    }
}

New-Alias -Name imiset -Value Import-ISETheme -Description 'Short-hand for Import-ISETheme command in the ISEThemes PowerShell module.' -Force -ErrorAction Ignore