Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 232869

Re: PowerCli : Read from URL

$
0
0

If I understand that condition correctly, you could do something like this

 

$url="http://server-name/folder/hosts_in_mm_list.txt"$reply=Invoke-WebRequest$url$tgtHosts="host1","host2","host3"
$tgtComment
="Target comment"
$hostnames
=$reply.Content|%$hostname,$comment=$_.Split(','if($tgtHosts-contains$hostname-and$tgtComment-eq$comment){    $hostname
  } }

 

I assume that the content can be handled line by line. If not, there probably needs to be a split on <CR> or <LF> or both.

The input is split, line by line, on the comma.

In $tgtHosts I have the names of the hosts you are looking for.

In $tgtComment I have the comment text you are looking for.

All hostnames that fit the condition are stored in $hostnames.


Viewing all articles
Browse latest Browse all 232869

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>