none
Cannot get value from true/false field (checkbox) RRS feed

  • Question

  • I'm trying to get value from true/false field which is used as checkbox data container in Outlook custom forms.

    Here is how I get value from text fields in powershell script.

    foreach($Item in $fiItems.Items) {    

    $psPropset = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties) #Custom fields $CustomFields = @( "Start", "End", "SbsProgramName", "SbsProgramHosts", "SbsProgramDesc", "SbsProgramPicture", "SbsProgramPageLink", "SbsNotifyBar", "SbsNotifyBarTopic", "SbsNotifyBarText", "SbsNotifyBarLink", "SbsNotifyBarLinkText", "SbsNotifyBarLinkType", "SbsRadiotFiTsl" ) foreach($Field in $CustomFields) { #Create extended properties $CustomField = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition([Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet]::PublicStrings,$Field,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::String); #Add extended properties to properties set $psPropset.Add($CustomField); } #Load properties into current appointment $Item.Load($psPropset); #Loop extended properties in the table foreach($ExtendedProperty in $Item.ExtendedProperties) { $ExtendedProperty.PropertyDefinition.Name + ": " + $ExtendedProperty.Value }

    }

    The "SbsNotifyBar" and "SbsRadiotFiTsl" are true/false fields, all other are text fields. Those true/false fields won't even print in powershell console (last loop).

    Do I need load those properties some different way?

    Monday, October 3, 2016 5:12 PM

Answers

  • I would pipe the object representing that property to Get-Member, to reveal the class and all properties available. Perhaps it is class CheckBox, in which case it has a CheckState property (or something similar). If CheckState is "Checked", that would be the same as true.

    When $ExtendedProperty.PropertyDefinition.Name is equal to SbsNotifyBar, pipe $ExtendedProperty (or perhaps $ExtendedProperty.PropertyDefinition) to the Get-Member cmdlet.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Friday, October 21, 2016 3:27 PM

All replies

  • Hi Haapti,

    from the description of the thread I looks like you are codding in Windows power shell script ise.

    so the issue is more related with powershell forum.

    so I move this thread to powershell forum.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 6, 2016 3:57 AM
  • Hi haapti,

    >> Those true/false fields won't even print in powershell console (last loop).

    See this sample:

    $test1 = @{'t1'=$true;'t2'=$false}
    foreach($t in $test1)
    {
        echo $t
    }

    Best regards,

    Andy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Saturday, October 8, 2016 3:19 AM
    Moderator
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Andy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, October 21, 2016 9:09 AM
    Moderator
  • I would pipe the object representing that property to Get-Member, to reveal the class and all properties available. Perhaps it is class CheckBox, in which case it has a CheckState property (or something similar). If CheckState is "Checked", that would be the same as true.

    When $ExtendedProperty.PropertyDefinition.Name is equal to SbsNotifyBar, pipe $ExtendedProperty (or perhaps $ExtendedProperty.PropertyDefinition) to the Get-Member cmdlet.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Friday, October 21, 2016 3:27 PM