Notices: This section not yet converted to new layout. Download stats are rolling back out.

Get-ChildItemColor (PowerShell Module)

1.2.3

Package test results are passing.

This package was approved by moderator gep13 on 5/23/2018.

Get-ChildItemColor provides colored version of Get-ChildItem Cmdlet and Get-ChildItem | Format-Wide (ls equivalent).

  • This adds colors to the output of Get-ChildItem Cmdlet of PowerShell. It is based on Tim Johnson’s script and another script by the PowerShell Guy.
  • Before version 1.0.0, the script actually had used Write-Host to write colored items on console. Now it just changes $Host.UI.RawUI.ForegroundColor and keep the item object intact. Hence, now one can use pipeline. (e.g., ~Get-ChildItemColor | grep “.git”~).
  • Get-ChildItemColorFormatWide still uses Write-Host for output however. This is because Get-ChildItemColor | Format-Wide does not allow multiple colors in one line. Hence, pipeline does not work with Get-ChildItemColorFormatWide.

NOTE: This is an automatically updated package. If you find it is out of date by more than a week, please contact the maintainer(s) and let them know the package is no longer updating correctly.

To install Get-ChildItemColor (PowerShell Module), run the following command from the command line or from PowerShell:

C:\> choco install get-childitemcolor

To upgrade Get-ChildItemColor (PowerShell Module), run the following command from the command line or from PowerShell:

C:\> choco upgrade get-childitemcolor

Files

Hide
  • tools\.skipAutoUninstaller
  • tools\chocolateyBeforeModify.ps1 Show
    $ErrorActionPreference = 'Stop'
    
    $moduleName = $env:ChocolateyPackageName      # this could be different from package name
    Remove-Module -Name $moduleName -Force -ErrorAction SilentlyContinue
  • tools\chocolateyInstall.ps1 Show
    $ErrorActionPreference = 'Stop'
    
    $toolsDir   = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
    $moduleName = $env:ChocolateyPackageName  # this may be different from the package name and different case
    
    # module may already be installed outside of Chocolatey
    Remove-Module -Name $moduleName -Force -ErrorAction SilentlyContinue
    
    $sourcePath = Join-Path -Path $toolsDir -ChildPath "$modulename\*"
    $destPath   = Join-Path -Path $env:ProgramFiles -ChildPath "WindowsPowerShell\Modules\$moduleName"
    
    if ($PSVersionTable.PSVersion.Major -ge 5)
    {
        $manifestFile = Join-Path -Path $toolsDir -ChildPath "$moduleName\$moduleName.psd1"
        $manifest     = Test-ModuleManifest -Path $manifestFile -WarningAction Ignore -ErrorAction Stop
        $destPath     = Join-Path -Path $destPath -ChildPath $manifest.Version.ToString()
    }
    
    Write-Verbose "Creating destination directory '$destPath' for module."
    New-Item -Path $destPath -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null
    
    Write-Verbose "Moving '$moduleName' files from '$sourcePath' to '$destPath'."
    Move-Item -Path $sourcePath -Destination $destPath -Force
    
    if ($PSVersionTable.PSVersion.Major -lt 4)
    {
        $modulePaths = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine') -split ';'
        if ($modulePaths -notcontains $destPath)
        {
            Write-Verbose "Adding '$destPath' to PSModulePath."
            $newModulePath = @($destPath, $modulePaths) -join ';'
    
            [Environment]::SetEnvironmentVariable('PSModulePath', $newModulePath, 'Machine')
            $env:PSModulePath = $newModulePath
        }
    }
  • tools\VERIFICATION.txt Show
    VERIFICATION
    Verification is intended to assist the Chocolatey moderators and community in verifying that this package's contents are trustworthy.
    
    To verify the files using the project source:
    
    1. Please go to the project source location (https://github.com/joonro/Get-ChildItemColor) and download the source files;
    2. Build the source to create the binary files to verify;
    3. Use Get-FileHash -Path <FILE TO VERIFY> to get the file hash value from both the built file (from step 1 above) and the file from the package and compare them;
    
    Alternatively you can download the module from the PowerShell Gallery ...
    
        Save-Module -Name Get-ChildItemColor -Path <PATH TO DOWNLOAD TO>
    
    ... and compare the files from the package against those in the installed module. Again use Get-FileHash -Path <FILE TO VERIFY> to retrieve those hash values.
  • tools\LICENSE.txt Show
    From: https://github.com/joonro/Get-ChildItemColor/blob/master/LICENSE
    
    MIT License
    
    Copyright (c) 2018 Joon Ro
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    
    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
  • tools\Get-ChildItemColor\screenshots\Get-ChildItemColorFormatWide.png
  • tools\Get-ChildItemColor\screenshots\Get-ChildItemColor.png
  • tools\Get-ChildItemColor\README.org
  • tools\Get-ChildItemColor\PSGetModuleInfo.xml Show
    <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
      <Obj RefId="0">
        <TN RefId="0">
          <T>Microsoft.PowerShell.Commands.PSRepositoryItemInfo</T>
          <T>System.Management.Automation.PSCustomObject</T>
          <T>System.Object</T>
        </TN>
        <MS>
          <S N="Name">Get-ChildItemColor</S>
          <Version N="Version">1.2.3</Version>
          <S N="Type">Module</S>
          <S N="Description">Get-ChildItemColor provides colored version of Get-ChildItem Cmdlet and Get-ChildItem | Format-Wide (ls equivalent)</S>
          <S N="Author">Joon Ro</S>
          <S N="CompanyName">joonro</S>
          <S N="Copyright">(c) 2018 Joon Ro. All rights reserved.</S>
          <DT N="PublishedDate">2018-05-15T05:43:32+00:00</DT>
          <Nil N="InstalledDate" />
          <Nil N="UpdatedDate" />
          <Nil N="LicenseUri" />
          <URI N="ProjectUri">https://github.com/joonro/Get-ChildItemColor</URI>
          <Nil N="IconUri" />
          <Obj N="Tags" RefId="1">
            <TN RefId="1">
              <T>System.Object[]</T>
              <T>System.Array</T>
              <T>System.Object</T>
            </TN>
            <LST>
              <S>Get-ChildItem</S>
              <S>ls</S>
              <S>Color</S>
              <S>PSModule</S>
            </LST>
          </Obj>
          <Obj N="Includes" RefId="2">
            <TN RefId="2">
              <T>System.Collections.Hashtable</T>
              <T>System.Object</T>
            </TN>
            <DCT>
              <En>
                <S N="Key">Function</S>
                <Obj N="Value" RefId="3">
                  <TNRef RefId="1" />
                  <LST>
                    <S>Get-ChildItemColor</S>
                    <S>Get-ChildItemColorFormatWide</S>
                  </LST>
                </Obj>
              </En>
              <En>
                <S N="Key">RoleCapability</S>
                <Obj N="Value" RefId="4">
                  <TNRef RefId="1" />
                  <LST />
                </Obj>
              </En>
              <En>
                <S N="Key">Command</S>
                <Obj N="Value" RefId="5">
                  <TNRef RefId="1" />
                  <LST>
                    <S>Get-ChildItemColor</S>
                    <S>Get-ChildItemColorFormatWide</S>
                  </LST>
                </Obj>
              </En>
              <En>
                <S N="Key">DscResource</S>
                <Obj N="Value" RefId="6">
                  <TNRef RefId="1" />
                  <LST />
                </Obj>
              </En>
              <En>
                <S N="Key">Workflow</S>
                <Obj N="Value" RefId="7">
                  <TNRef RefId="1" />
                  <LST />
                </Obj>
              </En>
              <En>
                <S N="Key">Cmdlet</S>
                <Obj N="Value" RefId="8">
                  <TNRef RefId="1" />
                  <LST />
                </Obj>
              </En>
            </DCT>
          </Obj>
          <Nil N="PowerShellGetFormatVersion" />
          <Nil N="ReleaseNotes" />
          <Obj N="Dependencies" RefId="9">
            <TNRef RefId="1" />
            <LST />
          </Obj>
          <S N="RepositorySourceLocation">https://www.powershellgallery.com/api/v2/</S>
          <S N="Repository">PSGallery</S>
          <S N="PackageManagementProvider">NuGet</S>
          <Obj N="AdditionalMetadata" RefId="10">
            <TNRef RefId="2" />
            <DCT>
              <En>
                <S N="Key">versionDownloadCount</S>
                <S N="Value">67</S>
              </En>
              <En>
                <S N="Key">ItemType</S>
                <S N="Value">Module</S>
              </En>
              <En>
                <S N="Key">copyright</S>
                <S N="Value">(c) 2018 Joon Ro. All rights reserved.</S>
              </En>
              <En>
                <S N="Key">description</S>
                <S N="Value">Get-ChildItemColor provides colored version of Get-ChildItem Cmdlet and Get-ChildItem | Format-Wide (ls equivalent)</S>
              </En>
              <En>
                <S N="Key">created</S>
                <S N="Value">5/15/2018 5:43:32 AM +00:00</S>
              </En>
              <En>
                <S N="Key">published</S>
                <S N="Value">5/15/2018 5:43:32 AM +00:00</S>
              </En>
              <En>
                <S N="Key">developmentDependency</S>
                <S N="Value">False</S>
              </En>
              <En>
                <S N="Key">NormalizedVersion</S>
                <S N="Value">1.2.3</S>
              </En>
              <En>
                <S N="Key">downloadCount</S>
                <S N="Value">3242</S>
              </En>
              <En>
                <S N="Key">GUID</S>
                <S N="Value">52c0ddeb-6767-42c0-89ad-203df97b22d1</S>
              </En>
              <En>
                <S N="Key">tags</S>
                <S N="Value">Get-ChildItem ls Color PSModule PSFunction_Get-ChildItemColor PSCommand_Get-ChildItemColor PSFunction_Get-ChildItemColorFormatWide PSCommand_Get-ChildItemColorFormatWide PSIncludes_Function</S>
              </En>
              <En>
                <S N="Key">updated</S>
                <S N="Value">2018-05-18T20:08:14Z</S>
              </En>
              <En>
                <S N="Key">isLatestVersion</S>
                <S N="Value">True</S>
              </En>
              <En>
                <S N="Key">IsPrerelease</S>
                <S N="Value">false</S>
              </En>
              <En>
                <S N="Key">isAbsoluteLatestVersion</S>
                <S N="Value">True</S>
              </En>
              <En>
                <S N="Key">packageSize</S>
                <S N="Value">100934</S>
              </En>
              <En>
                <S N="Key">FileList</S>
                <S N="Value">Get-ChildItemColor.nuspec|Get-ChildItemColor.psd1|Get-ChildItemColor.psm1|LICENSE|README.org|devel\Get-ChildItemColor%20debug.ps1|devel\zcpub-Freeman_Virtual-Freeman_Virtual-CmsTempVm.rdp|example\config.ini|example\dll.dll|example\executable.exe|example\others|example\text.txt|screenshots\Get-ChildItemColor.png|screenshots\Get-ChildItemColorFormatWide.png</S>
              </En>
              <En>
                <S N="Key">requireLicenseAcceptance</S>
                <S N="Value">False</S>
              </En>
            </DCT>
          </Obj>
          <S N="InstalledLocation">C:\Users\appveyor\AppData\Local\Temp\1\a9b57142-e7c8-401a-bb70-d7b907efa14d\Get-ChildItemColor\1.2.3</S>
        </MS>
      </Obj>
    </Objs>
    
  • tools\Get-ChildItemColor\LICENSE
  • tools\Get-ChildItemColor\Get-ChildItemColor.psm1 Show
    $OriginalForegroundColor = $Host.UI.RawUI.ForegroundColor
    if ([System.Enum]::IsDefined([System.ConsoleColor], 1) -eq "False") { $OriginalForegroundColor = "Gray" }
    
    $CompressedList = @(".7z", ".gz", ".rar", ".tar", ".zip")
    $ExecutableList = @(".exe", ".bat", ".cmd", ".py", ".pl", ".ps1",
                        ".psm1", ".vbs", ".rb", ".reg", ".fsx", ".sh")
    $DllPdbList = @(".dll", ".pdb")
    $TextList = @(".csv", ".log", ".markdown", ".rst", ".txt")
    $ConfigsList = @(".cfg", ".conf", ".config", ".ini", ".json")
    
    $ColorTable = @{}
    
    $ColorTable.Add('Default', $OriginalForegroundColor) 
    $ColorTable.Add('Directory', "Green") 
    
    ForEach ($Extension in $CompressedList) {
        $ColorTable.Add($Extension, "Yellow")
    }
    
    ForEach ($Extension in $ExecutableList) {
        $ColorTable.Add($Extension, "Blue")
    }
    
    ForEach ($Extension in $TextList) {
        $ColorTable.Add($Extension, "Cyan")
    }
    
    ForEach ($Extension in $DllPdbList) {
        $ColorTable.Add($Extension, "DarkGreen")
    }
    
    ForEach ($Extension in $ConfigsList) {
        $ColorTable.Add($Extension, "DarkYellow")
    }
    
    
    Function Get-Color($Item) {
        $Key = 'Default'
    
        If ($Item.GetType().Name -eq 'DirectoryInfo') {
            $Key = 'Directory'
        } Else {
            If ($Item.PSobject.Properties.Name -contains "Extension") {
                If ($ColorTable.ContainsKey($Item.Extension)) {
                    $Key = $Item.Extension
                }
            }
        }
    
        $Color = $ColorTable[$Key]
        Return $Color
    }
    
    
    Function Get-ChildItemColor {
        Param(
            [string]$Path = ""
        )
        $Expression = "Get-ChildItem -Path `"$Path`" $Args"
    
        $Items = Invoke-Expression $Expression
    
        ForEach ($Item in $Items) {
            $Color = Get-Color $Item
    
            $Host.UI.RawUI.ForegroundColor = $Color
            $Item
            $Host.UI.RawUI.ForegroundColor = $OriginalForegroundColor
        }
    }
    
    Function Get-ChildItemColorFormatWide {
        Param(
            [string]$Path = "",
            [switch]$Force
        )
    
        $nnl = $True
    
        $Expression = "Get-ChildItem -Path `"$Path`" $Args"
    
        if ($Force) {$Expression += " -Force"}
    
        $Items = Invoke-Expression $Expression
    
        $lnStr = $Items | Select-Object Name | Sort-Object { "$_".Length } -Descending | Select-Object -First 1
        $len = $lnStr.Name.Length
        $width = $Host.UI.RawUI.WindowSize.Width
        $cols = If ($len) {[math]::Floor(($width + 1) / ($len + 2))} Else {1}
        if (!$cols) {$cols = 1}
    
        $i = 0
        $pad = [math]::Ceiling(($width + 2) / $cols) - 3
    
        ForEach ($Item in $Items) {
            If ($Item.PSobject.Properties.Name -contains "PSParentPath") {
                If ($Item.PSParentPath -match "FileSystem") {
                    $ParentType = "Directory"
                    $ParentName = $Item.PSParentPath.Replace("Microsoft.PowerShell.Core\FileSystem::", "")
                }
                ElseIf ($Item.PSParentPath -match "Registry") {
                    $ParentType = "Hive"
                    $ParentName = $Item.PSParentPath.Replace("Microsoft.PowerShell.Core\Registry::", "")
                }
            } Else {
                $ParentType = ""
                $ParentName = ""
                $LastParentName = $ParentName
            }
    
            $Color = Get-Color $Item
    
            If ($LastParentName -ne $ParentName) {
                If($i -ne 0 -AND $Host.UI.RawUI.CursorPosition.X -ne 0){  # conditionally add an empty line
                    Write-Host ""
                }
                Write-Host -Fore $OriginalForegroundColor ("`n   $($ParentType): $ParentName`n")
            }
    
            $nnl = ++$i % $cols -ne 0
    
            # truncate the item name
            $toWrite = $Item.Name
            If ($toWrite.length -gt $pad) {
                $toWrite = $toWrite.Substring(0, $pad - 3) + "..."
            }
    
            Write-Host ("{0,-$pad}" -f $toWrite) -Fore $Color -NoNewLine:$nnl
    
            If ($nnl) {
                Write-Host "  " -NoNewLine
            }
    
            $LastParentName = $ParentName
        }
    
        If ($nnl) {  # conditionally add an empty line
            Write-Host ""
            Write-Host ""
        }
    }
    
    Export-ModuleMember -Function 'Get-*'
    
  • tools\Get-ChildItemColor\Get-ChildItemColor.psd1 Show
    #
    # Module manifest for module 'Get-ChildItemColor'
    #
    # Generated by: Joon Ro
    #
    # Generated on: 5/14/2018 20:17PM
    #
    
    @{
    
    # Script module or binary module file associated with this manifest.
    RootModule = 'Get-ChildItemColor.psm1'
    
    # Version number of this module.
    ModuleVersion = '1.2.3'
    
    # Supported PSEditions
    # CompatiblePSEditions = @()
    
    # ID used to uniquely identify this module
    GUID = '52c0ddeb-6767-42c0-89ad-203df97b22d1'
    
    # Author of this module
    Author = 'Joon Ro'
    
    # Company or vendor of this module
    CompanyName = ''
    
    # Copyright statement for this module
    Copyright = '(c) 2018 Joon Ro. All rights reserved.'
    
    # Description of the functionality provided by this module
    Description = 'Get-ChildItemColor provides colored version of Get-ChildItem Cmdlet and Get-ChildItem | Format-Wide (ls equivalent)'
    
    # Minimum version of the Windows PowerShell engine required by this module
    # PowerShellVersion = ''
    
    # Name of the Windows PowerShell host required by this module
    # PowerShellHostName = ''
    
    # Minimum version of the Windows PowerShell host required by this module
    # PowerShellHostVersion = ''
    
    # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
    # DotNetFrameworkVersion = ''
    
    # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
    # CLRVersion = ''
    
    # Processor architecture (None, X86, Amd64) required by this module
    # ProcessorArchitecture = ''
    
    # Modules that must be imported into the global environment prior to importing this module
    # RequiredModules = @()
    
    # Assemblies that must be loaded prior to importing this module
    # RequiredAssemblies = @()
    
    # Script files (.ps1) that are run in the caller's environment prior to importing this module.
    # ScriptsToProcess = @()
    
    # Type files (.ps1xml) to be loaded when importing this module
    # TypesToProcess = @()
    
    # Format files (.ps1xml) to be loaded when importing this module
    # FormatsToProcess = @()
    
    # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
    # NestedModules = @()
    
    # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
    FunctionsToExport = @(
        'Get-ChildItemColor',
        'Get-ChildItemColorFormatWide'
    )
    
    # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
    CmdletsToExport = @()
    
    # Variables to export from this module
    VariablesToExport = @()
    
    # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
    AliasesToExport = @()
    
    # DSC resources to export from this module
    # DscResourcesToExport = @()
    
    # List of all modules packaged with this module
    # ModuleList = @()
    
    # List of all files packaged with this module
    # FileList = @()
    
    # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
    PrivateData = @{
    
        PSData = @{
    
            # Tags applied to this module. These help with module discovery in online galleries.
            Tags = @('Get-ChildItem', 'ls', 'Color')
    
            # A URL to the license for this module.
            # LicenseUri = ''
    
            # A URL to the main website for this project.
            ProjectUri = 'https://github.com/joonro/Get-ChildItemColor'
    
            # A URL to an icon representing this module.
            # IconUri = ''
    
            # ReleaseNotes of this module
            # ReleaseNotes = ''
    
        } # End of PSData hashtable
    
    } # End of PrivateData hashtable
    
    # HelpInfo URI of this module
    # HelpInfoURI = ''
    
    # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
    # DefaultCommandPrefix = ''
    
    }
    
  • tools\Get-ChildItemColor\example\text.txt Show
    text
    
  • tools\Get-ChildItemColor\example\others
  • tools\Get-ChildItemColor\example\executable.exe Show
    md5: B4569F3306EE7FA0D12A5183C765ECA6 | sha1: F40E27F484B1C1D40C7E41975E037698566456C5 | sha256: 936BB0212022006B73258E9B1850641E75732047CFDC6AE7E4424C7FCFBB08D9 | sha512: 2F38CA5F8B0B92C441ADBA7EDFD6E9F93D1FD1B585A773E15C7A7CBE1049B4378A6FC36B3FFEE380089C8816D9445BB60C1B622A6A582B721F264B848A8719F5
  • tools\Get-ChildItemColor\example\dll.dll Show
    md5: 865BB2A6B500A08746D494B802649C45 | sha1: 504ED073FF320A3D8E4842AAD8DE8D035178A297 | sha256: 911421D9760CA578A0CAAAE9E34A0290926D47C191EC051F91F02B7EB4196471 | sha512: 553E40BF346A0FBB5226FB25B2031783F402EC1C2A6CE214AAB54CA8EF2C73C623D3B4A99992BD79CAF6E8E5E3747F1DB2B69ED0111DCEB82F6239E9E28F4F0F
  • tools\Get-ChildItemColor\example\config.ini Show
    config
    
  • tools\Get-ChildItemColor\devel\zcpub-Freeman_Virtual-Freeman_Virtual-CmsTempVm.rdp
  • tools\Get-ChildItemColor\devel\Get-ChildItemColor debug.ps1 Show
    $OriginalForegroundColor = $Host.UI.RawUI.ForegroundColor
    if ([System.Enum]::IsDefined([System.ConsoleColor], 1) -eq "False") { $OriginalForegroundColor = "Gray" }
    
    $CompressedList = @(".7z", ".gz", ".rar", ".tar", ".zip")
    $ExecutableList = @(".exe", ".bat", ".cmd", ".py", ".pl", ".ps1",
                        ".psm1", ".vbs", ".rb", ".reg", ".fsx", ".sh")
    $DllPdbList = @(".dll", ".pdb")
    $TextList = @(".csv", ".log", ".markdown", ".rst", ".txt")
    $ConfigsList = @(".cfg", ".conf", ".config", ".ini", ".json")
    
    $ColorTable = @{}
    
    $ColorTable.Add('Default', $OriginalForegroundColor) 
    $ColorTable.Add('Directory', "Green") 
    
    ForEach ($Extension in $CompressedList) {
        $ColorTable.Add($Extension, "Yellow")
    }
    
    ForEach ($Extension in $ExecutableList) {
        $ColorTable.Add($Extension, "Blue")
    }
    
    ForEach ($Extension in $TextList) {
        $ColorTable.Add($Extension, "Cyan")
    }
    
    ForEach ($Extension in $DllPdbList) {
        $ColorTable.Add($Extension, "DarkGreen")
    }
    
    ForEach ($Extension in $ConfigsList) {
        $ColorTable.Add($Extension, "DarkYellow")
    }
    
    
    Function Get-Color($Item) {
        $Key = 'Default'
    
        If ($Item.GetType().Name -eq 'DirectoryInfo') {
            $Key = 'Directory'
        } Else {
            If ($Item.PSobject.Properties.Name -contains "Extension") {
                If ($ColorTable.ContainsKey($Item.Extension)) {
                    $Key = $Item.Extension
                }
            }
        }
    
        $Color = $ColorTable[$Key]
        Return $Color
    }
    
    
    
    
        $Path = "~"
        $Force = $false
    
        $nnl = $True
    
        $Expression = "Get-ChildItem -Path `"$Path`" $Args"
    
        if ($Force) {$Expression += " -Force"}
    
        $Items = Invoke-Expression $Expression
    
        $lnStr = $Items | Select-Object Name | Sort-Object { "$_".Length } -Descending | Select-Object -First 1
        $len = $lnStr.Name.Length
        $width = $Host.UI.RawUI.WindowSize.Width
        $cols = If ($len) {[math]::Floor(($width + 1) / ($len + 2))} Else {1}
        if (!$cols) {$cols = 1}
    
        $i = 0
        $pad = [math]::Ceiling(($width + 2) / $cols) - 3
    
        ForEach ($Item in $Items) {
            If ($Item.PSobject.Properties.Name -contains "PSParentPath") {
                If ($Item.PSParentPath -match "FileSystem") {
                    $ParentType = "Directory"
                    $ParentName = $Item.PSParentPath.Replace("Microsoft.PowerShell.Core\FileSystem::", "")
                }
                ElseIf ($Item.PSParentPath -match "Registry") {
                    $ParentType = "Hive"
                    $ParentName = $Item.PSParentPath.Replace("Microsoft.PowerShell.Core\Registry::", "")
                }
            } Else {
                $ParentType = ""
                $ParentName = ""
                $LastParentName = $ParentName
            }
    
            $Color = Get-Color $Item
    
            If ($LastParentName -ne $ParentName) {
                If($i -ne 0 -AND $Host.UI.RawUI.CursorPosition.X -ne 0){  # conditionally add an empty line
                    Write-Host ""
                }
                Write-Host -Fore $OriginalForegroundColor ("`n   $($ParentType): $ParentName`n")
            }
    
            $nnl = ++$i % $cols -ne 0
    
            # truncate the item name
            $toWrite = $Item.Name
            If ($toWrite.length -gt $pad) {
                $toWrite = $toWrite.Substring(0, $pad - 3) + "..."
            }
    
            Write-Host ("{0,-$pad}" -f $toWrite) -Fore $Color -NoNewLine:$nnl
    
            If ($nnl) {
                Write-Host "  " -NoNewLine
            }
    
            $LastParentName = $ParentName
    
            If ($Item.Name.Substring(0, 4) -eq "cpub") {
               Write-Host "Breaking!"
                 Break }
        }
    
        If ($nnl) {  # conditionally add an empty line
            Write-Host ""
            Write-Host ""
        }
    
    
    
  • tools\chocolateyUninstall.ps1 Show
    $ErrorActionPreference = 'Stop'
    
    $moduleName = $env:ChocolateyPackageName
    $sourcePath = Join-Path -Path $env:ProgramFiles -ChildPath "WindowsPowerShell\Modules\$moduleName"
    
    Write-Verbose "Removing all version of '$moduleName' from '$sourcePath'."
    Remove-Item -Path $sourcePath -Recurse -Force -ErrorAction SilentlyContinue
    
    if ($PSVersionTable.PSVersion.Major -lt 4) {
        $modulePaths = [Environment]::GetEnvironmentVariable('PSModulePath', 'Machine') -split ';'
    
        Write-Verbose "Removing '$sourcePath' from PSModulePath."
        $newModulePath = $modulePaths | Where-Object { $_ -ne $sourcePath }
    
        [Environment]::SetEnvironmentVariable('PSModulePath', $newModulePath, 'Machine')
        $env:PSModulePath = $newModulePath
    }

Virus Scan Results

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Dependencies

This package has no dependencies.

Package Maintainer(s)

Software Author(s)

  • Joon Ro

Copyright

2018 Joon Ro

Tags

Release Notes

https://github.com/joonro/Get-ChildItemColor#changelog

Version History

Version Downloads Last updated Status

Discussion for the Get-ChildItemColor (PowerShell Module) Package

Ground rules:

  • This discussion is only about Get-ChildItemColor (PowerShell Module) and the Get-ChildItemColor (PowerShell Module) package. If you have feedback for Chocolatey, please contact the google group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or Get-ChildItemColor (PowerShell Module), or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.

comments powered by Disqus
Chocolatey.org uses cookies to enhance the user experience of the site.
Ok