0

Trying to get list of IP addresses of computers that have files open (in a particular path) on a server. What I have so far kind of works but the output is more than just the IP address.

$pcnames=get-smbopenfile | where {$_.Path -Like "E:\data\subfolder"} | select-object -property clientcomputername # | format-table -hidetableheaders 

foreach ($pc in $pcnames) {
    write-host $pc
 }

The output from this is:

@{clientcomputername=10.10.11.22}

@{clientcomputername=10.10.11.23}

etc.

How do it get the output to be just:

10.10.11.22

10.10.11.23

JPoole
  • 305
  • 3
  • 13

1 Answers1

0

Adding .clientComputerName returns just the IP address:

write-host $pc.clientcomputername

JPoole
  • 305
  • 3
  • 13
  • 2
    You should also add some explanation of your code, so it becomes helpful for the OP and the future readers. – Wasif Aug 16 '20 at 07:52