forked from hsmalley/Powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-PrivateProfileString.ps1
33 lines (27 loc) · 1.04 KB
/
Get-PrivateProfileString.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
##############################################################################
##
## Get-PrivateProfileString.ps1
##
## http://www.leeholmes.com/blog/2007/10/02/managing-ini-files-with-powershell/
##
## Get an entry from an INI file.
##
## ie:
##
## PS >Get-PrivateProfileString.ps1 C:\winnt\system32\ntfrsrep.ini text DEV_CTR_24_009_HELP
##
##############################################################################
param(
$file,
$category,
$key)
## Prepare the parameter types and parameter values for the Invoke-WindowsApi script
$returnValue = New-Object System.Text.StringBuilder 500
$parameterTypes = [string], [string], [string], [System.Text.StringBuilder], [int], [string]
$parameters = [string] $category, [string] $key, [string] “”,
[System.Text.StringBuilder] $returnValue, [int] $returnValue.Capacity, [string] $file
## Invoke the API
[void] (Invoke-WindowsApi “kernel32.dll” ([UInt32]) “GetPrivateProfileString” `
$parameterTypes $parameters)
## And return the results
$returnValue.ToString()