# "translate results"

**URL:** <https://forums.powershell.org/t/translate-results/16455>\
**Category:** PowerShell Help\
**Created:** [May 7, 2021, 12:40am UTC](https://forums.powershell.org/t/translate-results/16455 "2021-05-07T00:40:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![turbo-mcp](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@turbo-mcp](https://forums.powershell.org/u/turbo-mcp)\
**Post date:** [May 7, 2021, 12:40am UTC](https://forums.powershell.org/t/translate-results/16455/1 "2021-05-07T00:40:33Z")

</div>

Hi there  
I have a script that goes after certain values of attributes in azure  
most of attributes are straight forward so like true/false id name  
one of them is not the “real” value so it returns 0,1,2,3,4,5 which translate to their real values created manually somewhere like company1 company2 company3…  
the return values in table will look like this:

deviceName deviceEnrollmentType ownerType TagIds

* * *

WIN10GPO windowsCoManagement company {1}  
WIN10OFFICE userEnrollment company {0}

is there away I could show the ‘tagids’ as their real values?  
Thanks

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [May 7, 2021, 1:19am UTC](https://forums.powershell.org/t/translate-results/16455/2 "2021-05-07T01:19:44Z")

</div>

turbo,  
Welcome to the forums.

Usually curly braces indicate an array instead of a simple value. But without you sharing your code it’ll be hard to recommend something meaningful. You could try to use a

```auto
Select-Object -ExpandProperty TagIds

```

to expand the array.

---

<div class="post-metadata">

**Author:** ![turbo-mcp](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@turbo-mcp](https://forums.powershell.org/u/turbo-mcp)\
**Post date:** [May 7, 2021, 1:35am UTC](https://forums.powershell.org/t/translate-results/16455/3 "2021-05-07T01:35:35Z")

</div>

Thanks  
Yes this attribute can represent more than one value(in my case there will only be one value and that’s what i am after)  
i thought of maybe using switch with values translation

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [May 7, 2021, 6:23am UTC](https://forums.powershell.org/t/translate-results/16455/4 "2021-05-07T06:23:59Z")

</div>

> [@turbo-mcp](#):
>
> i thought of maybe using switch with values translation

I don’t get that. How about sharing your actual code?

---

<div class="post-metadata">

**Author:** ![turbo-mcp](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@turbo-mcp](https://forums.powershell.org/u/turbo-mcp)\
**Post date:** [May 7, 2021, 2:17pm UTC](https://forums.powershell.org/t/translate-results/16455/5 "2021-05-07T14:17:48Z")

</div>

i ended up doing something like this:  
$Results += [PSCustomObject] @{  
Devicename = $d.devicename  
DeviceEnrollmentType = $d.deviceEnrollmentType  
Ownertype = $d.ownertype  
DeviceCategoryDisplayName=$d.deviceCategoryDisplayName  
UserPrincipalName =$d.userPrincipalName  
EmailAddress=$d.emailAddress  
Id=$d.id  
Userid=$d.userId  
Operatingsystem=$d.operatingSystem  
Manageddevicename=$d.managedDeviceName  
RoleScopeTagIds=switch ($d.roleScopeTagIds){  
0 {“default”}  
1 {“realvalue1”}  
2 {“realvalue2”}

}

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [May 7, 2021, 2:46pm UTC](https://forums.powershell.org/t/translate-results/16455/6 "2021-05-07T14:46:22Z")

</div>

I assume your question is answered, right? 😉

Please format your code as code next time. It will look like this when you do:

```auto
[PSCustomObject] @{
    Devicename = $d.devicename
    DeviceEnrollmentType = $d.deviceEnrollmentType
    Ownertype = $d.ownertype
    DeviceCategoryDisplayName = $d.deviceCategoryDisplayName
    UserPrincipalName = $d.userPrincipalName
    EmailAddress = $d.emailAddress
    Id = $d.id
    Userid = $d.userId
    Operatingsystem = $d.operatingSystem
    Manageddevicename = $d.managedDeviceName
    RoleScopeTagIds = switch ($d.roleScopeTagIds) {
        0 { 'default' }
        1 { 'realvalue1' }
        2 { 'realvalue2' }
    }
}

```

Isn’t that much easier to read? 😉

---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [May 7, 2021, 4:20pm UTC](https://forums.powershell.org/t/translate-results/16455/7 "2021-05-07T16:20:38Z")

</div>

Much, much easier. And it’s easy to do!

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [May 7, 2021, 8:03pm UTC](https://forums.powershell.org/t/translate-results/16455/8 "2021-05-07T20:03:46Z")

</div>

To answer your question, it’s an array, so you need to process it with a for loop to convert each tag in the array to the real value. Also, using += is not an efficient way to build objects, just put a variable in front of the loop and everything that is returned rolls up to that variable:

```auto
$results = foreach ($d in $devices) {
    [PSCustomObject] @{
        Devicename = $d.devicename
        DeviceEnrollmentType = $d.deviceEnrollmentType
        Ownertype = $d.ownertype
        DeviceCategoryDisplayName = $d.deviceCategoryDisplayName
        UserPrincipalName = $d.userPrincipalName
        EmailAddress = $d.emailAddress
        Id = $d.id
        Userid = $d.userId
        Operatingsystem = $d.operatingSystem
        Manageddevicename = $d.managedDeviceName
        RoleScopeTagIds = foreach ($tag in $d.roleScopeTagIds) {
            switch ($tag) {
                0 { 'default' }
                1 { 'realvalue1' }
                2 { 'realvalue2' }
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:26pm UTC](https://forums.powershell.org/t/translate-results/16455/9 "2024-05-16T20:26:25Z")

</div>

Closed on May 16, 2024, 8:26pm UTC


