So, I have only been doing this blogging thing for a very short time (I am sure it shows in many ways) and I was cutely aware that when one does these things there is always the possibility of getting things wrong. I am sure this is why many people don’t put themselves out there like this. (I know being publicly ostracized is a major fear of mine!). But I did this blog because of this fear, to push myself out of my comfort zone and try something new.
I did a blog entry about what it is to be a Modern Workplace Engineer and the main point of that was to highlight the importance of open mindedness and curiosity. To that point I want to draw attention to another blog I did most recently on Intune install behaviour. Well, there was a better way to get that job done! (Big thanks to a mate at work for pointing it out to me)
So the point of the Blog is still valid and I hope it made sense as to why that option is there but… using the PSADT kit as I did, actually opened me up to doing it better under the system context as you can write into the Local User hive any way with the following code.
[scriptblock]$HKCURegistrySettings = {
Set-RegistryKey -Key 'HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Options\Mail' -Name 'JunkMailSafeSendersfile' -Value 'c:\[directory]\SafeSendersList.txt'-Type String -ContinueOnError:$True -SID $UserProfile.SID
Set-RegistryKey -Key 'HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Options\Mail' -Name 'JunkMailImportLists' -Value 1 -Type DWord -ContinueOnError:$True -SID $UserProfile.SID
}
Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings
This makes more sense as it doesn’t require me to modify the default behaviour of the PSADT kit in the first place just to get it to run without elevated permissions.
Moral of the story: keep you ego in check, stay open minded and keep looking for a better way.
Kommentit