# ConvertFrom-String and locating a specific object.

**URL:** <https://forums.powershell.org/t/convertfrom-string-and-locating-a-specific-object/8115>\
**Category:** PowerShell Help\
**Created:** [February 22, 2017, 2:01pm UTC](https://forums.powershell.org/t/convertfrom-string-and-locating-a-specific-object/8115 "2017-02-22T14:01:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![techtim2003yahoo-com](https://avatars.discourse-cdn.com/v4/letter/t/dfb087/32.png) [@techtim2003yahoo-com](https://forums.powershell.org/u/techtim2003yahoo-com)\
**Post date:** [February 22, 2017, 2:01pm UTC](https://forums.powershell.org/t/convertfrom-string-and-locating-a-specific-object/8115/1 "2017-02-22T14:01:36Z")

</div>

Setup:

```
$strings = "X-Possible-Header1:Value1X-Possible-Header2:Value2X-Possible-Header3:Value3X-File-Name:MyFileX-File-Size:32X-File-Type:PDFX-File-Date:04:22:78
"
$strings = $strings.Replace(":",":`r`n")
$strings = $strings.Replace("X-","`r`nX-")
$strings = $strings | ConvertFrom-String
$strings
```

The possible headers in the example above may or may not be there. So then with the convertfrom-string provides the P# objects the order can change.

Ask:

I am trying to figure out how to locate a statically named object and take the value of the next P# object which can be different.

So for example:  
P8 : X-File-Name  
P9 : MyFile

How would I locate X-File-Name regardless of its P# position and take P#+1 as the value I want returned.

---

<div class="post-metadata">

**Author:** ![techtim2003yahoo-com](https://avatars.discourse-cdn.com/v4/letter/t/dfb087/32.png) [@techtim2003yahoo-com](https://forums.powershell.org/u/techtim2003yahoo-com)\
**Post date:** [February 22, 2017, 2:03pm UTC](https://forums.powershell.org/t/convertfrom-string-and-locating-a-specific-object/8115/2 "2017-02-22T14:03:16Z")

</div>

Setup:

```
$strings = "X-Possible-Header1:Value1X-Possible-Header2:Value2X-Possible-Header3:Value3X-File-Name:MyFileX-File-Size:32X-File-Type:PDFX-File-Date:04:22:78
"
$strings = $strings.Replace(":",":`r`n")
$strings = $strings.Replace("X-","`r`nX-")
$strings = $strings | ConvertFrom-String
$strings
```

The possible headers in the example above may or may not be there. So then with the convertfrom-string provides the P# objects the order can change.

Ask:

I am trying to figure out how to locate a statically named object and take the value of the next P# object which can be different.

So for example:  
P8 : X-File-Name  
P9 : MyFile

How would I locate X-File-Name regardless of its P# position and take P#+1 as the value I want returned.

---

<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:39pm UTC](https://forums.powershell.org/t/convertfrom-string-and-locating-a-specific-object/8115/3 "2024-05-16T20:39:14Z")

</div>


