@@ -2,30 +2,34 @@ Function Set-BloggerConfig
22{
33 [CmdletBinding ()]
44 Param (
5+ [Parameter (Mandatory = $true )]
56 [ValidateSet (" BlogId" , " PandocAdditionalArgs" , " PandocHtmlFormat" , " PandocMarkdownFormat" )]
67 [string ]$Name ,
78
9+ [Parameter (Mandatory = $true )]
10+ [AllowEmptyString ()]
811 [string ]$Value
912 )
10-
11- $userPreferences = @ {}
13+ $userPreferences = [pscustomobject ]@ {}
1214
1315 if (Test-Path $BloggerSession.UserPreferences )
1416 {
15- Write-Verbose " Loading preferences from $ ( $BloggerSession.UserPreferences ) "
16- $userPreferences = Get-Content $BloggerSession.UserPreferences | ConvertFrom-Json
17+ Write-Verbose " Set-BloggerConfig: Loading preferences from $ ( $BloggerSession.UserPreferences ) "
18+ $userPreferences = [pscustomobject ](Get-Content $BloggerSession.UserPreferences - Raw | ConvertFrom-Json )
19+ $userPreferences | Out-String | Write-Verbose
1720 }
1821
19- if ($userPreferences.PsObject.Properties. Name -notcontains $ Name )
22+ if (@ ( $userPreferences.PsObject.Properties ).Count -eq 0 -or $ Name -notin $userPreferences .PsObject.Properties. Name )
2023 {
21- Write-Verbose " Adding Property $Name "
24+ Write-Verbose " Set-BloggerConfig: Adding Property $Name "
2225 $userPreferences | Add-Member - Name $Name - Value $Value - MemberType NoteProperty
2326 }
2427 else {
25- Write-Verbose " Updating Propery $Name "
28+ Write-Verbose " Set-BloggerConfig: Updating Propery $Name "
2629 $userPreferences .$Name = $Value
2730 }
2831
32+ Write-Verbose " Set-BloggerConfig: Saving preferences to $ ( $BloggerSession.UserPreferences ) "
2933 Set-Content - Path $BloggerSession.UserPreferences - Value ($userPreferences | ConvertTo-Json )
3034 $BloggerSession .$Name = $Value
3135}
0 commit comments