C
C
ChildOfDark2015-08-24 21:46:44
PowerShell
ChildOfDark, 2015-08-24 21:46:44

How in PowerShell to make the result of netsh wlan show hostednetwork written to a file when the number of clients > 0?

There is a script (my first script)

do
{
    netsh wlan show hostednetwork | Out-File D:\test.txt -append
    date | Out-File D:\test.txt -append
    Start-Sleep -Seconds 15
    
}while(1)

It is necessary that the recording to the file goes when the number of clients is greater than 0.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anatoly, 2015-09-01
@ChildOfDark

while ($true) {
    $output = netsh wlan show hostednetwork
    [int]$count = ($output | sls 'Number of clients').ToString().split(':')[1]
    if ($count -gt 0) {
        date | Out-File D:\test.txt -append
    }
    Start-Sleep -Seconds 15
}

M
MrDywar Pichugin, 2015-08-24
@Dywar

Use a pipeline.https://ru.wikipedia.org/wiki/Windows_PowerShell
some data | your condition, check for number of records | save to log

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question