Closed hvdm closed 1 month ago
Very odd since I haven't made any changes to this in quite awhile. But, I have duplicated the problem. Investigating.
Even though the JSON file has a value for the cooked state, when you import the module all the vegetables are raw by design. This is so you can learn to write code like your script. Still, I should update the documentation to make this clear.
I am busy with the Pluralsight Fundamental course (12 of them :o) and your screen examples shows up with the values from the Json file. Thats why I asumed that it was wrong.
Maybe it's better that you load those values by default, it will match the courses you made.
Alright. You convinced me.
Thanks
Update to v4.3.0 of the PSTeachingTools module from the PowerShell Gallery.
Thank you for the quick fix, works as expected
Describe the problem
Made a post in Pluralsight as well. All vegetables are RAW when you do a Get-Vegatable. It looks like the rawveggies.json isn't processed correctly.
Expectation
When running my FixVegatbles.ps1 in each session, it's working as it should be.
$docFolder = ([Environment]::GetFolderPath("MyDocuments")) $rawPath = Join-Path -path "$docFolder\PowerShell\Modules\PSTeachingTools\4.2.0\Code" -ChildPath rawveggies.json
$json = Get-Content -path $rawPath | ConvertFrom-Json
$StatusMap = @{ 0 = 'Raw' 1 = 'Boiled' 2 = 'Steamed' 3 = 'Sauteed' 4 = 'Fried' 5 = 'Baked' 6 = 'Roasted' 7 = 'Grilled' }
foreach ($vegetable in $json) { $name = $vegetable.Name $oldState = (Get-Vegetable -Name $vegetable.Name).CookedState [int32]$newState = $vegetable.Cookingstate [string]$newStateName = $StatusMap[$newState]
}
Additional Information
The above script works but needs to be run anytime again. Happens on 5.1 as on 7.4.5
PowerShell version
Other
Platform
Windows 10 Pro or Enterprise
Additional Checks