Posts

Showing posts from 2022

Converting nested hashtables(or yaml) to nested psobject with PowerShell

Image
I'm dabbling with WinGet at work, and I wanted to parse the installer information about VLC Media Player provided by WinGet .  PowerShell does not natively support Yaml, so I like to use the powershell-yaml module. I thought a simple convert should be enough, but no. This just resulted in a hashtable, I wanted a psobject. So how about casting ut to a psobject? Better, at first I thought I was done. But hold on, the properties of Installers are still hashtables. Googling and thinking led me to almost use a recursive function that dealt with this, but then I remembered playing around with conversions between yaml and json. Side note, the UI config of Home Assistant may be edited as yaml, but is stored as json on disk. So I knew they are just different flavors of the same thing, really.  Anyways, this is how to convert yaml to nested psobects: Get-Content <file.yaml> | ConvertFrom-Yaml | ConvertTo-Json | ConvertFrom-Json (I added -Depth 5 just because the default value 2 is not

I think I found a bug in cmtrace

Image
At work today I was looking through a log file generated by PSADT and noticed something weird. Compare the selected line in blue and the box below. Can you see it? (cmtrace version 5.0.9068.1000, I believe this is the current up to date version) Hint: The folder in ccmcache for the content is named "n".  Now, compare this to an older version of cmtrace where we see the same log file (cmtrace version 5.0.7804.1000, some years old) In case it's not clear: (new/current cmtrace. where is the n folder? For some reason, "\n" is getting removed from the box below in the new version of cmtrace.  My guess why this is happening: \n can be interpretet as a newline character. I believe this is happening, and in addition it strips away newlines. So "\n" just vanishes. The older version does not have this issue. That's all for now, have a great day!

VIRDIestimat i Google Sheets

Image
 Hei! (This will be in Norwegian, as it only applies to norwegians or people wanting to buy or sell real estate in Norway) (tldr i fet skrift mot slutten) Dere kjenner kanskje til virdi.no  (Min eneste relasjon til den tjenesten er som bruker). Det er kort fortalt en tjeneste som gir estimerte boligverdier. Men boligprisene endrer seg over tid, og jeg liker i alle fall å ha en idé om hva min bolig er verdt (ifølge Virdi). Det er en smal sak å bokmerke siden for min leilighet og sjekke en gang iblant, men jeg liker også å integrere dette tallet med andre nøkkeltall i min økonomi. Her kommer Google Sheets inn i bildet.  Jeg ønsker å kunne hente tallet fra Virdi automatisk, inn i en celle i Google Sheets.  Sånn gjør du det: Finn boligen på virdi.no. Her bruker jeg en helt tilfeldig leilighet som eksempel. Linken du skal ende opp med skal se ut som dette: https://virdi.no/bolig/oslo/0368-oslo/kirkeveien-37a/H0201 Her skal du kunne se VIRDIestimatet, som dette:  (Teksten "12 328 700&qu