# Server name in output

**URL:** <https://forums.powershell.org/t/server-name-in-output/9001>\
**Category:** PowerShell Help\
**Created:** [July 12, 2017, 11:47am UTC](https://forums.powershell.org/t/server-name-in-output/9001 "2017-07-12T11:47:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![venkata-kalyan](https://avatars.discourse-cdn.com/v4/letter/v/b3f665/32.png) [@venkata-kalyan](https://forums.powershell.org/u/venkata-kalyan)\
**Post date:** [July 12, 2017, 11:47am UTC](https://forums.powershell.org/t/server-name-in-output/9001/1 "2017-07-12T11:47:40Z")

</div>

Hi,  
I trying to get service which running with specific account on remote servers. I am able to achieve it, but in output, I am not able to get the server name.

import-csv test.csv | foreach {

Get-WmiObject -Class Win32\_Service -ComputerName $_.computer | where {$_.StartName -eq ‘domain\user’} | select Server, Name, DisplayName, StartName

} | Export-Csv C:\Users\test\Desktop\Test\Search\_String\result.csv -NoType

Can someone guide me, what I am missing?

-Kalyan

---

<div class="post-metadata">

**Author:** ![will-anderson](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/will-anderson/32/234_2.png) [@will-anderson](https://forums.powershell.org/u/will-anderson)\
**Post date:** [July 12, 2017, 12:18pm UTC](https://forums.powershell.org/t/server-name-in-output/9001/2 "2017-07-12T12:18:51Z")

</div>

Hey there Venkata. Server is not a property output by that command. Try running SELECT -first 1 -property \* and see what fits best. PSComputerName is usually a good one to use.

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [July 12, 2017, 12:32pm UTC](https://forums.powershell.org/t/server-name-in-output/9001/3 "2017-07-12T12:32:45Z")

</div>

Well, because you’re working with what’s emitted by Get-WmiObject, you need to have what you need already there, or attach it.

Have you seen if PowerShell is adding a PSComputerName property to the output of Get-WmiObject?

---

<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:** [July 12, 2017, 8:22pm UTC](https://forums.powershell.org/t/server-name-in-output/9001/4 "2017-07-12T20:22:12Z")

</div>

```
import-csv test.csv | foreach {

Get-WmiObject -Class Win32_Service -ComputerName $_.computer | 
where {$_.StartName -eq 'domain\user'} | 
select PSComputerName, #possible automatic variable filled with computername
       @{Name="Server";Expression={$_.computer}}, #manually populate name with calculated property
       Name, 
       DisplayName, 
       StartName

} | Export-Csv C:\Users\test\Desktop\Test\Search_String\result.csv -NoType
```

---

<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:37pm UTC](https://forums.powershell.org/t/server-name-in-output/9001/5 "2024-05-16T20:37:54Z")

</div>

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


