[ gogi100 @ 16.12.2020. 07:26 ] @
dakle, imam cisco vpn client klijenta koji ima svoj virutelni adapter. potrebno je pratiti da li je taj adapter enablovan ili disablovan i na bazi toga disablovati servis network list service ili kad je disablovan staviti ovaj servis u stanje manual. ja sam pokusao sa register-wmievent, ali to ne radi. moja skripta je Code: Function UpNetwork { $up = “Up” $lan = “Cisco Systems VPN Adapter for 64-bit Windows” $lanUp = Get-NetAdapter | select interfacedescription,Status | where { $_.Status -match $up -and $_.interfacedescription -match $lan } $servicerunning = Get-Service netprofm | select status,starttype | where { $_.Status -match $running -and $_.starttype -match $manual } if ($lanUp) { If($servicerunning) { Get-Service netprofm | Stop-Service -PassThru | Set-Service -StartupType disabled } } } Function DownNetwork { $disabled = “Disabled” $lan = “Cisco Systems VPN Adapter for 64-bit Windows” $landown = Get-NetAdapter | select interfacedescription,Status | where { $_.Status -match $disabled -and $_.interfacedescription -match $lan } $servicestopped = Get-Service netprofm | select status,starttype | where { $_.starttype -match $disabled } if ($landown) { if($servicestopped) { Get-Service netprofm | Set-Service -StartupType Manual | Start-Service } } } Register-WMIEvent -Namespace root\wmi -Class MSNdis_StatusMediaConnect -Action {UpNetwork} Register-WMIEvent -Namespace root\wmi -Class MSNdis_StatusMediaDisconnect -Action {DownNetwork} Exit dobijam sledece Id Name PSJobTypeName State HasMoreData Location Command — —- ————- —– ———– ——– ——- 1 d16f5266-065… NotStarted False UpNetwork 2 e51af08a-528… NotStarted False DownNetwork negde postoji, greska. mozete li mi pomoci? [Ovu poruku je menjao gogi100 dana 16.12.2020. u 09:15 GMT+1] |