get a service from a list of remote computers.


hi,

i run this:

$computerlist = get-content -path "p:\tools\x64.txt"
$computerlist | foreach { (get-service -name yam* -computername $_) | select-object machinename, name, displayname, status}
<# need add line extract if yam not installed  #>
$computerlist | foreach -ne { (get-service -name yam* -computername $_) | select-object machinename}

the first 2 lines produce expected result.  last line can not work.  looking list computers not have service installed.  example if have pc1, pc2 , pc3, pc4 i list, , 1 , 2 have service,  i list below

machinename                name                  displayname                          status

pc1                                 yam                           yam                                 running

pc2                                  yam                          yam                                 running

pc3      

pc4

any thoughts.

thanks in advance.                 

$computerlist | where {$exsts.machinename -contains $_}

or

$computerlist | where {$computerlist -contains  (get-service -name winrm* -computername $_).machinename }

thanks azam when see answers please mark answer if helpful..vote helpful.



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Windows 2016 RDS event 1306 Connection Broker Client failed to redirect the user... Error: NULL