Powershell Umgang mit PSObject
Hallo,
ich hab eine gui und will ein Profil speichern bzw. laden können.
Ob die Checkbox gecheckt sein soll oder nicht will icht jetzt auslesen...
Es möchte nur nicht so wie ich will...
Profile.ini:
Problem ist, ich komme nicht so recht an das Value um es der Richtigen Checkbox zuzuordnen.
ich hab eine gui und will ein Profil speichern bzw. laden können.
Ob die Checkbox gecheckt sein soll oder nicht will icht jetzt auslesen...
Es möchte nur nicht so wie ich will...
Profile.ini:
[profil1]
checkbox1=checked
checkbox2=checked
checkbox3=unchecked
checkbox4=checked
[profil2]
checkbox6=checked
$Global:Profilepath = "$env:Appdata\Profiles\Profile.ini"
#(Get-IniContet: https://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91)
$Global:Profiles=Get-IniContent $Profilepath
$ProfilesNames= New-Object PSObject –Property @{
Checkbox1 = $profiles.Values.GetEnumerator() |sort values |select -Index 0
Checkbox2 = $profiles.Values.GetEnumerator() |sort values |select -Index 1
Checkbox3 = $profiles.Values.GetEnumerator() |sort values |select -Index 2
Checkbox4 = $profiles.Values.GetEnumerator() |sort values |select -Index 3
Checkbox5 = $profiles.Values.GetEnumerator() |sort values |select -Index 4
Checkbox6 = $profiles.Values.GetEnumerator() |sort values |select -Index 6
Checkbox7 = $profiles.Values.GetEnumerator() |sort values |select -Index 7
Checkbox8 = $profiles.Values.GetEnumerator() |sort values |select -Index 8
Checkbox9 = $profiles.Values.GetEnumerator() |sort values |select -Index 9
Checkbox10 = $profiles.Values.GetEnumerator() |sort values |select -Index 10
Checkbox11 = $profiles.Values.GetEnumerator() |sort values |select -Index 11
Checkbox12 = $profiles.Values.GetEnumerator() |sort values |select -Index 12
}
PS > $Profilesnames
Checkbox4 :
Checkbox2 : {checkbox3, checkbox4, checkbox1, checkbox2}
Checkbox6 :
Checkbox10 :
Checkbox9 :
Checkbox7 :
Checkbox12 :
Checkbox8 :
Checkbox1 : {checkbox6}
Checkbox5 :
Checkbox3 :
Checkbox11 :
PS > $Profilesnames.Checkbox1
Name Value
---- -----
checkbox6 checked
Problem ist, ich komme nicht so recht an das Value um es der Richtigen Checkbox zuzuordnen.
Please also mark the comments that contributed to the solution of the article
Content-Key: 271731
Url: https://administrator.de/contentid/271731
Printed on: April 26, 2024 at 08:04 o'clock
1 Comment
$ini = Get-IniContent "C:\temp\demo.ini"
$checkboxes_profil1 = $ini.GetEnumerator() | ?{$_.Name -eq "profil1" } | select -Expand Value
$checkboxes_profil1.GetEnumerator() | sort Name | %{
write-host "Checkbox: '$($_.Name)' hat den Wert '$($_.Value)'"
}