Skip to content

Add -Force parameter to Get-Item in Import-Ini to read hidden files #133

@koresent

Description

@koresent

Hi,

I've noticed that Import-Ini cannot read .ini files with the Hidden attribute, such as desktop.ini.

Currently, the code uses:

$source = (Get-Item -LiteralPath $source).FullName

This fails for hidden files:

Import-Ini -Path "$rootPath\desktop.ini"
Get-Item: Could not find item C:\Root\desktop.ini.
Import-Ini: Could not find file '

After adding the -Force parameter to Get-Item:

$source = (Get-Item -LiteralPath $source -Force).FullName

The import works correctly:

Import-Ini -Path "$rootPath\desktop.ini"
Name                           Value
----                           -----
.ShellClassInfo                {[LocalizedResourceName, Тест], [IconResource, %WINDIR%\System32\SHELL32.dll,84]}

Proposed fix:
Update line 120 in Import-Ini.ps1 to include -Force when calling Get-Item.

This should allow the module to read .ini files that are marked as hidden.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions