• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Checking network connections

H
#1
Hi,

How can i check the number of incoming network connections in PS. I'm
looking for something similar to net session. ?

Thanks
 
H
#3
Well i'm creating a backup script (to backup some MS-Access database), but i
want to check if any else in the network is still using the database. So
idea is to check the number of incoming network connections;


"Marco Shaw" <marco.shaw@_NO_SPAM_gmail.com> schreef in bericht
news:Oc0ud3p$HHA.4568@xxxxxx

> Hans wrote:

>> Hi,
>>
>> How can i check the number of incoming network connections in PS. I'm
>> looking for something similar to net session. ?
>>
>> Thanks
>
> Did you need anything additional? Because you can just run 'net session'
> directly from within PowerShell.
>
> Marco
>
> --
> ----------------
> PowerGadgets MVP
> http://www.powergadgets.com/mvp
>
> Blog:
> http://marcoshaw.blogspot.com
 
M

Marco Shaw

#4
Hans wrote:

> Well i'm creating a backup script (to backup some MS-Access database),
> but i want to check if any else in the network is still using the
> database. So idea is to check the number of incoming network connections;
You're best bet might be to check if there's a if there's a lock file
though.

But you can just call 'net session' directly:

PSH> net session
There are no entries in the list.

PSH> $result=net session
PSH> if ($result -like "*no entries*"){"no connections"}
no connections

Marco
 
O

/\/\o\/\/ [MVP]

#5
gwmi win32_serverSession might give the onfo you need

also you can use performance counters from PowerShell
see also
http://mow001.blogspot.com/2005/12/getting-performancemonitor-info-from.html

h.t.h.

Greetings /\/\o\/\/


"Hans" wrote:

> Well i'm creating a backup script (to backup some MS-Access database), but i
> want to check if any else in the network is still using the database. So
> idea is to check the number of incoming network connections;
>
>
> "Marco Shaw" <marco.shaw@_NO_SPAM_gmail.com> schreef in bericht
> news:Oc0ud3p$HHA.4568@xxxxxx

> > Hans wrote:

> >> Hi,
> >>
> >> How can i check the number of incoming network connections in PS. I'm
> >> looking for something similar to net session. ?
> >>
> >> Thanks
> >
> > Did you need anything additional? Because you can just run 'net session'
> > directly from within PowerShell.
> >
> > Marco
> >
> > --
> > ----------------
> > PowerGadgets MVP
> > http://www.powergadgets.com/mvp
> >
> > Blog:
> > http://marcoshaw.blogspot.com
>
>
 
K
#6
On Sep 24, 8:16 pm, "Hans" <hans.hant...@xxxxxx> wrote:

> Hi,
>
> How can i check the number of incoming network connections in PS. I'm
> looking for something similar to net session. ?
>
> Thanks
You can use something similar to this:
Get-WmiObject -ComputerName MYSERVER01 -Query {Select * From
Win32_ServerConnection Where NumberOfFiles>"0" and
ShareName="MYSHARE"} | Select-Object UserName,ShareName,NumberOfFiles
| Format-Table -autosize

This will work if the Database is the ONLY thing in the share. For
some reason I can't figure out a way to check specific open files
within shares just connections to a share that have files open.
Replace MYSERVER01 with your server name and MYSHARE with the share
name.