-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathGet-Desktop.ini.ps1
67 lines (58 loc) · 2.07 KB
/
Get-Desktop.ini.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
function Get-Desktop.ini {
<#
.SYNOPSIS
Gets the current Desktop.ini file for a particular folder
.DESCRIPTION
Gets the current Desktop.ini file for a particular folder from the hidden, system file Desktop.ini from the specified path
.PARAMETER Path
The path to the folder
.EXAMPLE
Assuming the file Desktop.ini exists in the current folder and contains:
Get-Content -Path .\Desktop.ini
[ViewState]
Mode=
Vid=
FolderType=Generic
[.ShellClassInfo]
InfoTip=This is hover over text
IconResource=TemporaryFolder2.ico,0
Get-Desktop.ini
Path FolderType InfoTip IconResource
---- ---------- ------- ------------
C:\Temp Generic This is hover over text TemporaryFolder2.ico,0
#>
[CmdletBinding()]
param (
[string] $Path = $pwd
)
begin {
Write-Verbose -Message "Starting [$($MyInvocation.Mycommand)]"
if (-not (Test-Path -Path $Path)) {
Write-Error "Path [$Path] does not exist."
break
} elseif (-not (Get-Item -Path $Path).PsIsContainer) {
Write-Error "Path [$Path] exists but is not a folder."
break
}
}
process {
$Desktop_ini = Join-Path -Path $Path -ChildPath 'Desktop.ini'
if (-not (Test-Path -Path $Desktop_ini)) {
Write-Error "No Desktop.ini found in [$Path]."
break
}
$Path = (Resolve-Path -Path $Path).Path
$FolderType = Get-PrivateProfileString -File $Desktop_ini -Section 'ViewState' -Key 'FolderType'
$InfoTip = Get-PrivateProfileString -File $Desktop_ini -Section '.ShellClassInfo' -Key 'InfoTip'
$IconResource = Get-PrivateProfileString -File $Desktop_ini -Section '.ShellClassInfo' -Key 'IconResource'
New-Object -TypeName psobject -Property ([ordered] @{
Path = $Path
FolderType = $FolderType
InfoTip = $InfoTip
IconResource = $IconResource
})
}
end {
Write-Verbose -Message "Ending [$($MyInvocation.Mycommand)]"
}
}