Problem with my script, dont execute

%3CLINGO-SUB%20id%3D%22lingo-sub-1175892%22%20slang%3D%22en-US%22%3EProblem%20with%20my%20script%2C%20dont%20execute%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1175892%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20to%20everyone%3CBR%20%2F%3EI%20have%20a%20script%20that%20is%20not%20working%20for%20me%20and%20I%20do%20not%20understand%20why%20%3F%2C%20my%20script%20tries%20to%20run%20a%20ping%20to%20selected%20machines%20as%20long%20as%20the%20computer%20is%20in%20a%20valid%20network%20to%20perform%20the%20ping%20and%20finally%20gives%20me%20a%20report%20in%20a%20file%2C%20in%20If%20a%20ping%20fails%20with%20a%20machine%2C%20I%20will%20display%20an%20alert%20window%20to%20take%20actions%2C%20but%20I%20really%20do%20not%20understand%20what%20happens%20with%20the%20script%20if%20you%20can%20guide%20me%20please%2C%20thank%20you%20very%20much.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%2B%2B%2B%20Powershell%20script%2B%2B%2B%2B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3EAdd-Type%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-AssemblyName%26nbsp%3BPresentationCore%2CPresentationFramework%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%24names%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EGet-content%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22C%3A%5CServers.txt%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24subname%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22%26nbsp%3B%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24chequea%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22no%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24dia%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EGet-date%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24ButtonType%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%26nbsp%3B%5B%3C%2FSPAN%3E%3CSPAN%3ESystem.Windows.MessageBoxButton%3C%2FSPAN%3E%3CSPAN%3E%5D%3A%3AOK%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24MessageIcon%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%26nbsp%3B%5B%3C%2FSPAN%3E%3CSPAN%3ESystem.Windows.MessageBoxImage%3C%2FSPAN%3E%3CSPAN%3E%5D%3A%3AError%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24MessageTitle%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22Falla%26nbsp%3Bde%26nbsp%3BAlcance%26nbsp%3Bpor%26nbsp%3BPing%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23%24ipV4%26nbsp%3B%3D%26nbsp%3BTest-Connection%26nbsp%3B-ComputerName%26nbsp%3B(hostname)%26nbsp%3B-Count%26nbsp%3B1%26nbsp%3B%26nbsp%3B%7C%26nbsp%3BSelect%26nbsp%3B-ExpandProperty%26nbsp%3BIPV4Address%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24ipV4%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3D%26nbsp%3B(%3C%2FSPAN%3E%3CSPAN%3EGet-NetAdapter%3C%2F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228.8.8.8%22%3C%2FSPAN%3E%3CSPAN%3E)%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24subname%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22DNS%26nbsp%3BGoogle%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3Eif%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B(%3C%2FSPAN%3E%3CSPAN%3E%24name%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-eq%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22%3CA%20href%3D%22http%3A%2F%2Fwww.google.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ewww.google.com%3C%2FA%3E%22%3C%2FSPAN%3E%3CSPAN%3E)%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24subname%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22Dominio%26nbsp%3BGoogle%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3Eif%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B(%3C%2FSPAN%3E%3CSPAN%3E%24name%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B-eq%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22192.168.5.1%22%3C%2FSPAN%3E%3CSPAN%3E)%7B%3C%2FSPAN%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C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1175892%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1183004%22%20slang%3D%22en-US%22%3ERe%3A%20Problem%20with%20my%20script%2C%20dont%20execute%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1183004%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F554353%22%20target%3D%22_blank%22%3E%40Nervill_mcbo%3C%2FA%3E%26nbsp%3B%20are%20you%20getting%20an%20error%3F%20Or%20what%20is%20not%20working%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1183224%22%20slang%3D%22en-US%22%3ERe%3A%20Problem%20with%20my%20script%2C%20dont%20execute%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1183224%22%20slang%3D%22en-US%22%3ENot%20working%20Erick!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1183249%22%20slang%3D%22en-US%22%3ERe%3A%20Problem%20with%20my%20script%2C%20dont%20execute%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1183249%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F554353%22%20target%3D%22_blank%22%3E%40Nervill_mcbo%3C%2FA%3E%26nbsp%3BSo%2C%20you%20mean%20no%20output%20at%20all%3F%20No%20error%2C%20no%20results%2C%20right%3F%20I'm%20going%20to%20try%20to%20run%20it%20in%20my%20system%20and%20brb.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1183311%22%20slang%3D%22en-US%22%3ERe%3A%20Problem%20with%20my%20script%2C%20dont%20execute%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1183311%22%20slang%3D%22en-US%22%3Ewhen%20I%20set%20the%20variable%20wanting%20to%20get%20the%20IP%20value%20of%20the%20active%20network%2C%20it%20stopped%20working%20completely%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1183395%22%20slang%3D%22en-US%22%3ERe%3A%20Problem%20with%20my%20script%2C%20dont%20execute%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1183395%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F554353%22%20target%3D%22_blank%22%3E%40Nervill_mcbo%3C%2FA%3E%26nbsp%3BI've%20modified%20your%20script%20to%20fix%20the%20errors%20that%20it%20was%20throwing%20for%20the%20GetAddressBytes()%20and%20the%20way%20the%20array%20of%20adapters%20were%20listed.%26nbsp%3B%3CBR%20%2F%3EIt%20is%20working%20on%20my%20system%2C%20so%20please%20let%20me%20know%20how%20it%20goes%20now.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3EAdd-Type%20-AssemblyName%20PresentationCore%2CPresentationFramework%0A%0A%24names%20%3D%20Get-content%20%22C%3A%5CServers.txt%22%0A%24subname%3D%22%20%22%0A%24chequea%3D%22no%22%0A%24dia%20%3D%20Get-date%0A%24ButtonType%20%3D%20%5BSystem.Windows.MessageBoxButton%5D%3A%3AOK%0A%24MessageIcon%20%3D%20%5BSystem.Windows.MessageBoxImage%5D%3A%3AError%0A%24MessageTitle%20%3D%20%22Falla%20de%20Alcance%20por%20Ping%22%0A%0A%23%24ipV4%20%3D%20Test-Connection%20-ComputerName%20(hostname)%20-Count%201%20%20%7C%20Select%20-ExpandProperty%20IPV4Address%0A%24ipsV4%20%3D%20%24(Get-NetAdapter%20-Physical%20%7C%20where%20status%20-eq%20'up'%20%7C%20Get-NetIPAddress%20%7C%20where%7B%24_.AddressFamily%20-eq%20'IPv4'%7D).IPAddress%20%0A%0A%23Write-Verbose%20%24ipV4.IPAddressToString%0AForeach(%24ipV4_tmp%20in%20%24ipsV4)%20%23added%20due%20that%20multiple%20Adapter%20could%20be%20up%0A%20%7B%0A%20%20%24ipV4%20%3D%20%24null%0A%20%20%5BSystem.Net.IPAddress%5D%24ipV4%20%3D%20%24ipV4_tmp%0A%20%20Write-Host%20%24ipV4.IPAddressToString%0A%0A%20%20If(%24ipV4_tmp)%0A%20%20%20%7B%0A%20%20%20%20if%20(%24ipV4.GetAddressBytes()%5B0%5D%20-eq%20%22192%22%20-and%20%24ipV4.GetAddressBytes()%5B1%5D%20-eq%20%22168%22%20-and%20%24ipV4.GetAddressBytes()%5B2%5D%20-eq%20%225%22%20)%7B%0A%20%20%20%20%24chequea%3D%22si%22%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20if%20(%24ipV4.GetAddressBytes()%5B0%5D%20-eq%20%22192%22%20-and%20%24ipV4.GetAddressBytes()%5B1%5D%20-eq%20%22168%22%20-and%20%24ipV4.GetAddressBytes()%5B2%5D%20-eq%20%226%22%20)%7B%0A%20%20%20%20%24chequea%3D%22si%22%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%20%20if%20(%24ipV4.GetAddressBytes()%5B0%5D%20-eq%20%2210%22%20-and%20%24ipV4.GetAddressBytes()%5B1%5D%20-eq%20%22212%22%20-and%20%24ipV4.GetAddressBytes()%5B2%5D%20-eq%20%22134%22%20)%7B%0A%20%20%20%20%24chequea%3D%22si%22%0A%20%20%20%20%7D%0A%20%20%20%7D%0A%20%20Else%0A%20%20%20%7B%0A%20%20%20%20Write-Host%20%22Adapter%20IP%20item%20was%20empty%22%0A%20%20%20%7D%0A%20%7D%20%0A%0Aif(%24chequea%20-eq%20%22si%22)%7B%0A%0A%24Output%2B%3D%22%24dia%20%3A%20%22%0Aforeach%20(%24name%20in%20%24names)%7B%0A%0A%20if%20(Test-Connection%20-ComputerName%20%24name%20-Count%201%20-ErrorAction%20SilentlyContinue)%7B%0A%20%20%20%24Output%2B%3D%20%22%24name%20%3D%3D%3D%3D%26gt%3B%26gt%3B%20UP%20%7C%7C%20%22%0A%20%20%20Write-Host%20%22%24name%20%3D%3D%3D%3D%26gt%3B%26gt%3B%20UP%20%22%0A%20%20%20%23Write-Verbose%20%22%24name%20%3D%3D%3D%3D%26gt%3B%26gt%3B%20UP%20%22%0A%20%7D%0A%20else%7B%0A%20%20%20%20%0A%20%20%20%24Output%2B%3D%20%22%24name%20%3D%3D%3D%3D%26gt%3B%26gt%3B%20DOWN%20%7C%7C%20%22%0A%20%20%20Write-Host%20%22%24name%20%3D%3D%3D%3D%26gt%3B%26gt%3B%20DOWN%20%22%0A%20%20%20%23Write-Verbose%20%22%24name%20%3D%3D%3D%3D%26gt%3B%26gt%3B%20DOWN%20%22%0A%0A%20%20%20if%20(%24name%20-eq%20%228.8.8.8%22)%7B%0A%20%20%20%20%24subname%3D%22DNS%20Google%22%0A%7D%0A%20%20%20%0A%20%20%20if%20(%24name%20-eq%20%22www.google.com%22)%7B%0A%20%20%20%20%24subname%3D%22Dominio%20Google%22%0A%7D%0A%20%20%20%0A%20%20%20if%20(%24name%20-eq%20%22192.168.5.1%22)%7B%0A%20%20%20%20%24subname%3D%22Firewall%22%0A%7D%0A%20%20%20%0A%20%20%20if%20(%24name%20-eq%20%22192.168.5.2%22)%7B%0A%20%20%20%20%24subname%3D%22Server%2010%22%0A%7D%0A%20%20%20%0A%20%20%20if%20(%24name%20-eq%20%22192.168.5.30%22)%7B%0A%20%20%20%20%24subname%3D%22Server%208%22%0A%7D%0A%20%20%20%0A%20%20%20if%20(%24name%20-eq%20%22192.168.5.29%22)%7B%0A%20%20%20%20%24subname%3D%22Server%209%22%0A%7D%0A%20%20%20%0A%20%20%20if%20(%24name%20-eq%20%22192.168.5.52%22)%7B%0A%20%20%20%20%24subname%3D%22Server%207%22%0A%7D%0A%20%20%20%0A%20%20%20if%20(%24name%20-eq%20%22192.168.6.16%22)%7B%0A%20%20%20%20%24subname%3D%22Server%201%22%0A%7D%0A%20%20%20%0A%20%20%20if%20(%24name%20-eq%20%22192.168.5.94%22)%7B%0A%20%20%20%20%24subname%3D%22Server%202%22%0A%7D%0A%20%20%20%0A%20%20%20if%20(%24name%20-eq%20%22192.168.5.102%22)%7B%0A%20%20%20%20%24subname%3D%22Server%203%22%0A%7D%0A%20%20%20%0A%20%20%20if%20(%24name%20-eq%20%22192.168.5.43%22)%7B%0A%20%20%20%20%24subname%3D%22Server%204%22%0A%7D%0A%20%20%20%0A%20%20%20if%20(%24name%20-eq%20%22192.168.5.124%22)%7B%0A%20%20%20%20%24subname%3D%22Server%205%22%0A%7D%0A%20%20%20%0A%20%20%20if%20(%24name%20-eq%20%22192.168.6.250%22)%7B%0A%20%20%20%20%24subname%3D%22Impresora%20Wifi%22%0A%7D%0A%20%20%20%0A%20%20%20if%20(%24name%20-eq%20%22192.168.5.250%22)%7B%0A%20%20%20%20%24subname%3D%22Impresora%20Xerox%20%22%0A%7D%0A%20%20%20%24MessageBody%20%3D%20%22Conexion%20Perdida%20con%20el%20IP%3A%20%24name%2C%20%24subname%22%0A%20%20%20%24oReturn%3D%5BSystem.Windows.MessageBox%5D%3A%3AShow(%24MessageBody%2C%24MessageTitle%2C%24ButtonType%2C%24MessageIcon)%0A%20%7D%0A%20%20%7D%23foreach%0A%20%20%20%24Output%20%7C%20Out-file%20%22C%3A%5CPingResult.txt%22%20-Append%0A%20%20%7D%23If%0A%0A%20%0A%20%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1183596%22%20slang%3D%22en-US%22%3ERe%3A%20Problem%20with%20my%20script%2C%20dont%20execute%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1183596%22%20slang%3D%22en-US%22%3EHi%20%40Erick%3CBR%20%2F%3E%3CBR%20%2F%3EI%20have%20a%20doubt!%20because%20the%20ip%20of%20my%20vpn%20does%20not%20recognize%20me%20when%20I%20connect%2C%20what%20would%20the%20script%20lack%20so%20that%20when%20it%20finds%20that%20range%20of%20ip%20it%20will%20perform%20the%20operation%3F%3CBR%20%2F%3E%3CBR%20%2F%3Ethis%20is%20my%20ifconfig%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EConfiguraci%C3%B3n%20IP%20de%20Windows%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EAdaptador%20de%20Ethernet%20Ethernet%202%3A%3CBR%20%2F%3E%3CBR%20%2F%3EEstado%20de%20los%20medios.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20medios%20desconectados%3CBR%20%2F%3ESufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3A%3CBR%20%2F%3E%3CBR%20%2F%3EAdaptador%20de%20Ethernet%20Ethernet%203%3A%3CBR%20%2F%3E%3CBR%20%2F%3ESufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3A%3CBR%20%2F%3EV%C3%ADnculo%3A%20direcci%C3%B3n%20IPv6%20local.%20.%20.%20%3A%20fe80%3A%3A60e9%3Ac265%3A2745%3A5140%2518%3CBR%20%2F%3EDirecci%C3%B3n%20IPv4.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%2010.212.134.200%3CBR%20%2F%3EM%C3%A1scara%20de%20subred%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20255.255.255.255%3CBR%20%2F%3EPuerta%20de%20enlace%20predeterminada%20.%20.%20.%20.%20.%20%3A%3CBR%20%2F%3E%3CBR%20%2F%3EAdaptador%20de%20Ethernet%20Ethernet%3A%3CBR%20%2F%3E%3CBR%20%2F%3EEstado%20de%20los%20medios.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20medios%20desconectadosSufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3A%3CBR%20%2F%3E%3CBR%20%2F%3EAdaptador%20de%20LAN%20inal%C3%A1mbrica%20Conexi%C3%B3n%20de%20%C3%A1rea%20local*%201%3A%3CBR%20%2F%3E%3CBR%20%2F%3EEstado%20de%20los%20medios.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20medios%20desconectadosSufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3A%3CBR%20%2F%3E%3CBR%20%2F%3EAdaptador%20de%20LAN%20inal%C3%A1mbrica%20Conexi%C3%B3n%20de%20%C3%A1rea%20local*%2010%3A%3CBR%20%2F%3E%3CBR%20%2F%3EEstado%20de%20los%20medios.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20medios%20desconectadosSufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3A%3CBR%20%2F%3E%3CBR%20%2F%3EAdaptador%20de%20Ethernet%20VMware%20Network%20Adapter%20VMnet1%3A%3CBR%20%2F%3E%3CBR%20%2F%3ESufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3AV%C3%ADnculo%3A%20direcci%C3%B3n%20IPv6%20local.%20.%20.%20%3A%20fe80%3A%3A1008%3A6a5e%3Afda9%3A67c3%257%3CBR%20%2F%3EDirecci%C3%B3n%20IPv4.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20192.168.20.1%3CBR%20%2F%3EM%C3%A1scara%20de%20subred%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20255.255.255.0%3CBR%20%2F%3EPuerta%20de%20enlace%20predeterminada%20.%20.%20.%20.%20.%20%3A%3CBR%20%2F%3E%3CBR%20%2F%3EAdaptador%20de%20Ethernet%20VMware%20Network%20Adapter%20VMnet8%3A%3CBR%20%2F%3E%3CBR%20%2F%3ESufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3AV%C3%ADnculo%3A%20direcci%C3%B3n%20IPv6%20local.%20.%20.%20%3A%20fe80%3A%3A1931%3A2147%3Ae0f8%3Adca7%2519%3CBR%20%2F%3EDirecci%C3%B3n%20IPv4.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20192.168.111.1%3CBR%20%2F%3EM%C3%A1scara%20de%20subred%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20255.255.255.0Puerta%20de%20enlace%20predeterminada%20.%20.%20.%20.%20.%20%3A%3CBR%20%2F%3E%3CBR%20%2F%3EAdaptador%20de%20LAN%20inal%C3%A1mbrica%20Wi-Fi%3A%3CBR%20%2F%3E%3CBR%20%2F%3ESufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3A%20fibertel.com.ar%3CBR%20%2F%3EDirecci%C3%B3n%20IPv4.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20192.168.0.135%3CBR%20%2F%3EM%C3%A1scara%20de%20subred%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20255.255.255.0Puerta%20de%20enlace%20predeterminada%20.%20.%20.%20.%20.%20%3A%20192.168.0.1%3CBR%20%2F%3E%3CBR%20%2F%3EAdaptador%20de%20Ethernet%20Conexi%C3%B3n%20de%20red%20Bluetooth%3A%3CBR%20%2F%3E%3CBR%20%2F%3EEstado%20de%20los%20medios.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20medios%20desconectadosSufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3A%3CBR%20%2F%3E%3CBR%20%2F%3EAdaptador%20de%20Ethernet%20vEthernet%20(Default%20Switch)%3A%3CBR%20%2F%3E%3CBR%20%2F%3ESufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3AV%C3%ADnculo%3A%20direcci%C3%B3n%20IPv6%20local.%20.%20.%20%3A%20fe80%3A%3A817e%3A7ad%3A5feb%3A3f15%2526%3CBR%20%2F%3EDirecci%C3%B3n%20IPv4.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20192.168.209.177%3CBR%20%2F%3EM%C3%A1scara%20de%20subred%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20255.255.255.240%3CBR%20%2F%3EPuerta%20de%20enlace%20predeterminada%20.%20.%20.%20.%20.%20%3A%3CBR%20%2F%3EPS%20C%3A%5CUsers%5CLabsXD-1%5CDocuments%5CDevOps%5CcheckpingPowershell%26gt%3B%20ipconfig%3CBR%20%2F%3E%3CBR%20%2F%3EConfiguraci%C3%B3n%20IP%20de%20Windows%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EAdaptador%20de%20Ethernet%20Ethernet%202%3A%3CBR%20%2F%3E%3CBR%20%2F%3EEstado%20de%20los%20medios.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20medios%20desconectadosSufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3AAdaptador%20de%20Ethernet%20Ethernet%203%3ASufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3AV%C3%ADnculo%3A%20direcci%C3%B3n%20IPv6%20local.%20.%20.%20%3A%20fe80%3A%3A60e9%3Ac265%3A2745%3A5140%2518Direcci%C3%B3n%20IPv4.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%2010.212.134.200M%C3%A1scara%20de%20subred%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20255.255.255.255Puerta%20de%20enlace%20predeterminada%20.%20.%20.%20.%20.%20%3AAdaptador%20de%20Ethernet%20Ethernet%3AEstado%20de%20los%20medios.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20medios%20desconectadosSufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3AAdaptador%20de%20LAN%20inal%C3%A1mbrica%20Conexi%C3%B3n%20de%20%C3%A1rea%20local*%201%3AEstado%20de%20los%20medios.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20medios%20desconectadosSufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3AAdaptador%20de%20LAN%20inal%C3%A1mbrica%20Conexi%C3%B3n%20de%20%C3%A1rea%20local*%2010%3AEstado%20de%20los%20medios.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20medios%20desconectadosSufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3AAdaptador%20de%20Ethernet%20VMware%20Network%20Adapter%20VMnet1%3ASufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3AV%C3%ADnculo%3A%20direcci%C3%B3n%20IPv6%20local.%20.%20.%20%3A%20fe80%3A%3A1008%3A6a5e%3Afda9%3A67c3%257Direcci%C3%B3n%20IPv4.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20192.168.20.1M%C3%A1scara%20de%20subred%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20255.255.255.0Puerta%20de%20enlace%20predeterminada%20.%20.%20.%20.%20.%20%3AAdaptador%20de%20Ethernet%20VMware%20Network%20Adapter%20VMnet8%3ASufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3AV%C3%ADnculo%3A%20direcci%C3%B3n%20IPv6%20local.%20.%20.%20%3A%20fe80%3A%3A1931%3A2147%3Ae0f8%3Adca7%2519Direcci%C3%B3n%20IPv4.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20192.168.111.1M%C3%A1scara%20de%20subred%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20255.255.255.0Puerta%20de%20enlace%20predeterminada%20.%20.%20.%20.%20.%20%3AAdaptador%20de%20LAN%20inal%C3%A1mbrica%20Wi-Fi%3ASufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3A%20fibertel.com.arDirecci%C3%B3n%20IPv4.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20192.168.0.135M%C3%A1scara%20de%20subred%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20255.255.255.0Puerta%20de%20enlace%20predeterminada%20.%20.%20.%20.%20.%20%3A%20192.168.0.1Adaptador%20de%20Ethernet%20Conexi%C3%B3n%20de%20red%20Bluetooth%3AEstado%20de%20los%20medios.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20medios%20desconectadosSufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3AAdaptador%20de%20Ethernet%20vEthernet%20(Default%20Switch)%3ASufijo%20DNS%20espec%C3%ADfico%20para%20la%20conexi%C3%B3n.%20.%20%3AV%C3%ADnculo%3A%20direcci%C3%B3n%20IPv6%20local.%20.%20.%20%3A%20fe80%3A%3A817e%3A7ad%3A5feb%3A3f15%2526Direcci%C3%B3n%20IPv4.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20192.168.209.177M%C3%A1scara%20de%20subred%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3A%20255.255.255.240Puerta%20de%20enlace%20predeterminada%20.%20.%20.%20.%20.%20%3A%3CBR%20%2F%3E%3CBR%20%2F%3ERegards.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1183587%22%20slang%3D%22en-US%22%3ERe%3A%20Problem%20with%20my%20script%2C%20dont%20execute%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1183587%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F89674%22%20target%3D%22_blank%22%3E%40Erick%20A.%20Moreno%20R.%3C%2FA%3E%3CBR%20%2F%3EIt%20works%20perfect!%20I%20only%20have%20one%20doubt%20I%20try%20to%20have%20this%20script%20running%20on%20the%20scheduled%20tasks%20and%20it%20doesn't%20run%2C%20is%20it%20not%20the%20reason%3F%3CBR%20%2F%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello to everyone
I have a script that is not working for me and I do not understand why ?, my script tries to run a ping to selected machines as long as the computer is in a valid network to perform the ping and finally gives me a report in a file, in If a ping fails with a machine, I will display an alert window to take actions, but I really do not understand what happens with the script if you can guide me please, thank you very much.

 

+++ Powershell script++++

Add-Type -AssemblyName PresentationCore,PresentationFramework

$names = Get-content "C:\Servers.txt"
$subname=" "
$chequea="no"
$dia = Get-date
$ButtonType = [System.Windows.MessageBoxButton]::OK
$MessageIcon = [System.Windows.MessageBoxImage]::Error
$MessageTitle = "Falla de Alcance por Ping"

#$ipV4 = Test-Connection -ComputerName (hostname) -Count 1  | Select -ExpandProperty IPV4Address
$ipV4 = (Get-NetAdapter -Physical | where status -eq 'up' | Get-NetIPAddress).IPv4Address 
Write-Host $ipV4.IPAddressToString
#Write-Verbose $ipV4.IPAddressToString

if ($ipV4.GetAddressBytes()[0] -eq "192" -and $ipV4.GetAddressBytes()[1] -eq "168" -and $ipV4.GetAddressBytes()[2] -eq "5" ){
$chequea="si"
}

if ($ipV4.GetAddressBytes()[0] -eq "192" -and $ipV4.GetAddressBytes()[1] -eq "168" -and $ipV4.GetAddressBytes()[2] -eq "6" ){
$chequea="si"
}

if ($ipV4.GetAddressBytes()[0] -eq "10" -and $ipV4.GetAddressBytes()[1] -eq "212" -and $ipV4.GetAddressBytes()[2] -eq "134" ){
$chequea="si"
}

if($chequea -eq "si"){

$Output+="$dia : "
foreach ($name in $names){

 if (Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue){
   $Output+= "$name ====>> UP || "
   Write-Host "$name ====>> UP "
   #Write-Verbose "$name ====>> UP "
 }
 else{
    
   $Output+= "$name ====>> DOWN || "
   Write-Host "$name ====>> DOWN "
   #Write-Verbose "$name ====>> DOWN "

   if ($name -eq "8.8.8.8"){
    $subname="DNS Google"
}

if ($name -eq "www.google.com"){
    $subname="Dominio Google"
}

if ($name -eq "192.168.5.1"){
    $subname="Firewall"
}

if ($name -eq "192.168.5.2"){
    $subname="Server 10"
}

if ($name -eq "192.168.5.30"){
    $subname="Server 8"
}

if ($name -eq "192.168.5.29"){
    $subname="Server 9"
}

if ($name -eq "192.168.5.52"){
    $subname="Server 7"
}

if ($name -eq "192.168.6.16"){
    $subname="Server 1"
}

if ($name -eq "192.168.5.94"){
    $subname="Server 2"
}

if ($name -eq "192.168.5.102"){
    $subname="Server 3"
}

if ($name -eq "192.168.5.43"){
    $subname="Server 4"
}

if ($name -eq "192.168.5.124"){
    $subname="Server 5"
}

if ($name -eq "192.168.6.250"){
    $subname="Impresora Wifi"
}

if ($name -eq "192.168.5.250"){
    $subname="Impresora Xerox "
}
   $MessageBody = "Conexion Perdida con el IP: $name$subname"
   $oReturn=[System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
 }
}
$Output | Out-file "C:\PingResult.txt" -Append
}

 

23 Replies

@Nervill_mcbo  are you getting an error? Or what is not working?

Not working Erick!

@Nervill_mcbo So, you mean no output at all? No error, no results, right? I'm going to try to run it in my system and brb. 

 

Regards

when I set the variable wanting to get the IP value of the active network, it stopped working completely

@Nervill_mcbo I've modified your script to fix the errors that it was throwing for the GetAddressBytes() and the way the array of adapters were listed. 
It is working on my system, so please let me know how it goes now. 

Add-Type -AssemblyName PresentationCore,PresentationFramework

$names = Get-content "C:\Servers.txt"
$subname=" "
$chequea="no"
$dia = Get-date
$ButtonType = [System.Windows.MessageBoxButton]::OK
$MessageIcon = [System.Windows.MessageBoxImage]::Error
$MessageTitle = "Falla de Alcance por Ping"

#$ipV4 = Test-Connection -ComputerName (hostname) -Count 1  | Select -ExpandProperty IPV4Address
$ipsV4 = $(Get-NetAdapter -Physical | where status -eq 'up' | Get-NetIPAddress | where{$_.AddressFamily -eq 'IPv4'}).IPAddress 

#Write-Verbose $ipV4.IPAddressToString
Foreach($ipV4_tmp in $ipsV4) #added due that multiple Adapter could be up
 {
  $ipV4 = $null
  [System.Net.IPAddress]$ipV4 = $ipV4_tmp
  Write-Host $ipV4.IPAddressToString

  If($ipV4_tmp)
   {
    if ($ipV4.GetAddressBytes()[0] -eq "192" -and $ipV4.GetAddressBytes()[1] -eq "168" -and $ipV4.GetAddressBytes()[2] -eq "5" ){
    $chequea="si"
    }
    
    if ($ipV4.GetAddressBytes()[0] -eq "192" -and $ipV4.GetAddressBytes()[1] -eq "168" -and $ipV4.GetAddressBytes()[2] -eq "6" ){
    $chequea="si"
    }
    
    if ($ipV4.GetAddressBytes()[0] -eq "10" -and $ipV4.GetAddressBytes()[1] -eq "212" -and $ipV4.GetAddressBytes()[2] -eq "134" ){
    $chequea="si"
    }
   }
  Else
   {
    Write-Host "Adapter IP item was empty"
   }
 } 

if($chequea -eq "si"){

$Output+="$dia : "
foreach ($name in $names){

 if (Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue){
   $Output+= "$name ====>> UP || "
   Write-Host "$name ====>> UP "
   #Write-Verbose "$name ====>> UP "
 }
 else{
    
   $Output+= "$name ====>> DOWN || "
   Write-Host "$name ====>> DOWN "
   #Write-Verbose "$name ====>> DOWN "

   if ($name -eq "8.8.8.8"){
    $subname="DNS Google"
}
   
   if ($name -eq "www.google.com"){
    $subname="Dominio Google"
}
   
   if ($name -eq "192.168.5.1"){
    $subname="Firewall"
}
   
   if ($name -eq "192.168.5.2"){
    $subname="Server 10"
}
   
   if ($name -eq "192.168.5.30"){
    $subname="Server 8"
}
   
   if ($name -eq "192.168.5.29"){
    $subname="Server 9"
}
   
   if ($name -eq "192.168.5.52"){
    $subname="Server 7"
}
   
   if ($name -eq "192.168.6.16"){
    $subname="Server 1"
}
   
   if ($name -eq "192.168.5.94"){
    $subname="Server 2"
}
   
   if ($name -eq "192.168.5.102"){
    $subname="Server 3"
}
   
   if ($name -eq "192.168.5.43"){
    $subname="Server 4"
}
   
   if ($name -eq "192.168.5.124"){
    $subname="Server 5"
}
   
   if ($name -eq "192.168.6.250"){
    $subname="Impresora Wifi"
}
   
   if ($name -eq "192.168.5.250"){
    $subname="Impresora Xerox "
}
   $MessageBody = "Conexion Perdida con el IP: $name, $subname"
   $oReturn=[System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
 }
  }#foreach
   $Output | Out-file "C:\PingResult.txt" -Append
  }#If

 
 

 

@Erick A. Moreno R.
It works perfect! I only have one doubt I try to have this script running on the scheduled tasks and it doesn't run, is it not the reason?
 

Hi @Erick

I have a doubt! because the ip of my vpn does not recognize me when I connect, what would the script lack so that when it finds that range of ip it will perform the operation?

this is my ifconfig:


Configuración IP de Windows


Adaptador de Ethernet Ethernet 2:

Estado de los medios. . . . . . . . . . . : medios desconectados
Sufijo DNS específico para la conexión. . :

Adaptador de Ethernet Ethernet 3:

Sufijo DNS específico para la conexión. . :
Vínculo: dirección IPv6 local. . . : fe80::60e9:c265:2745:5140%18
Dirección IPv4. . . . . . . . . . . . . . : 10.212.134.200
Máscara de subred . . . . . . . . . . . . : 255.255.255.255
Puerta de enlace predeterminada . . . . . :

Adaptador de Ethernet Ethernet:

Estado de los medios. . . . . . . . . . . : medios desconectados
Sufijo DNS específico para la conexión. . :

Adaptador de LAN inalámbrica Conexión de área local* 1:

Estado de los medios. . . . . . . . . . . : medios desconectados
Sufijo DNS específico para la conexión. . :

Adaptador de LAN inalámbrica Conexión de área local* 10:

Estado de los medios. . . . . . . . . . . : medios desconectados
Sufijo DNS específico para la conexión. . :

Adaptador de Ethernet VMware Network Adapter VMnet1:

Sufijo DNS específico para la conexión. . :
Vínculo: dirección IPv6 local. . . : fe80::1008:6a5e:fda9:67c3%7
Dirección IPv4. . . . . . . . . . . . . . : 192.168.20.1
Máscara de subred . . . . . . . . . . . . : 255.255.255.0
Puerta de enlace predeterminada . . . . . :

Adaptador de Ethernet VMware Network Adapter VMnet8:

Sufijo DNS específico para la conexión. . :
Vínculo: dirección IPv6 local. . . : fe80::1931:2147:e0f8:dca7%19
Dirección IPv4. . . . . . . . . . . . . . : 192.168.111.1
Máscara de subred . . . . . . . . . . . . : 255.255.255.0
Puerta de enlace predeterminada . . . . . :

Adaptador de LAN inalámbrica Wi-Fi:

Sufijo DNS específico para la conexión. . : fibertel.com.ar
Dirección IPv4. . . . . . . . . . . . . . : 192.168.0.135
Máscara de subred . . . . . . . . . . . . : 255.255.255.0
Puerta de enlace predeterminada . . . . . : 192.168.0.1

Adaptador de Ethernet Conexión de red Bluetooth:

Estado de los medios. . . . . . . . . . . : medios desconectados
Sufijo DNS específico para la conexión. . :

Adaptador de Ethernet vEthernet (Default Switch):

Sufijo DNS específico para la conexión. . :
Vínculo: dirección IPv6 local. . . : fe80::817e:7ad:5feb:3f15%26
Dirección IPv4. . . . . . . . . . . . . . : 192.168.209.177
Máscara de subred . . . . . . . . . . . . : 255.255.255.240
Puerta de enlace predeterminada . . . . . :
PS C:\Users\LabsXD-1\Documents\DevOps\checkpingPowershell> ipconfig

Configuración IP de Windows


Adaptador de Ethernet Ethernet 2:

Estado de los medios. . . . . . . . . . . : medios desconectados
Sufijo DNS específico para la conexión. . :

Adaptador de Ethernet Ethernet 3:

Sufijo DNS específico para la conexión. . :
Vínculo: dirección IPv6 local. . . : fe80::60e9:c265:2745:5140%18
Dirección IPv4. . . . . . . . . . . . . . : 10.212.134.200
Máscara de subred . . . . . . . . . . . . : 255.255.255.255
Puerta de enlace predeterminada . . . . . :

Adaptador de Ethernet Ethernet:

Estado de los medios. . . . . . . . . . . : medios desconectados
Sufijo DNS específico para la conexión. . :

Adaptador de LAN inalámbrica Conexión de área local* 1:

Estado de los medios. . . . . . . . . . . : medios desconectados
Sufijo DNS específico para la conexión. . :

Adaptador de LAN inalámbrica Conexión de área local* 10:

Estado de los medios. . . . . . . . . . . : medios desconectados
Sufijo DNS específico para la conexión. . :

Adaptador de Ethernet VMware Network Adapter VMnet1:

Sufijo DNS específico para la conexión. . :
Vínculo: dirección IPv6 local. . . : fe80::1008:6a5e:fda9:67c3%7
Dirección IPv4. . . . . . . . . . . . . . : 192.168.20.1
Máscara de subred . . . . . . . . . . . . : 255.255.255.0
Puerta de enlace predeterminada . . . . . :

Adaptador de Ethernet VMware Network Adapter VMnet8:

Sufijo DNS específico para la conexión. . :
Vínculo: dirección IPv6 local. . . : fe80::1931:2147:e0f8:dca7%19
Dirección IPv4. . . . . . . . . . . . . . : 192.168.111.1
Máscara de subred . . . . . . . . . . . . : 255.255.255.0
Puerta de enlace predeterminada . . . . . :

Adaptador de LAN inalámbrica Wi-Fi:

Sufijo DNS específico para la conexión. . : fibertel.com.ar
Dirección IPv4. . . . . . . . . . . . . . : 192.168.0.135
Máscara de subred . . . . . . . . . . . . : 255.255.255.0
Puerta de enlace predeterminada . . . . . : 192.168.0.1

Adaptador de Ethernet Conexión de red Bluetooth:

Estado de los medios. . . . . . . . . . . : medios desconectados
Sufijo DNS específico para la conexión. . :

Adaptador de Ethernet vEthernet (Default Switch):

Sufijo DNS específico para la conexión. . :
Vínculo: dirección IPv6 local. . . : fe80::817e:7ad:5feb:3f15%26
Dirección IPv4. . . . . . . . . . . . . . : 192.168.209.177
Máscara de subred . . . . . . . . . . . . : 255.255.255.240
Puerta de enlace predeterminada . . . . . :

Regards.

@Nervill_mcbo 

What is the status when you run it through the task scheduler?

If I have to guess I would say it could be permissions issue as you are trying to write directly to C: other than that it depends on the environment. 

 

Regards

I change the path to this C: \ Users \ LabsXD-1 \ Documents \ checkpingPowershell
the error in the scheduled task is 0x41303 and it stays in running state and never runs and never ends

@Nervill_mcbo could you try to run it, with the argument -NonInteractive in the task scheduler? and see what is the result. 

 

Regards

Erick

It remains the same as the following program: Powershell argument: -NoneInteractive C: \ Users \ LabsXD-1 \ Documents \ checkpingPowershell \ CheckPing.ps1

@Nervill_mcbo It is weird, I have created a task to test it and its working fine, even without the additional argument. I'm attaching my settings in the tasks in case we have something different that could be messing with yours, probably playing with the time when the task first runs can help to clear that error.

For your question about the VPN, If I understood your question correctly you can use the task scheduler option to run it only when a specific connection is available and there you can select the one that corresponds to your VPN. 


Hello, what I am trying to do with the script is to check which of the NICs is in an up state and also contains one of the 3 network segments configured to run so that when detecting some of the IPSs the script is executed

@Nervill_mcbo Understand. Were you able to run it in the task scheduler? 

 

Regards

Copy your images and configure it, even though I think that the execution does not happen as I expect, when I check the result in the task it is always different from 0x0

@Nervill_mcbo After testing on a different machine I found something that may help. 
Please use the arguments -noninteractive -file "Pathtoscript.ps1" don't forget the quotes for your path as you can see in the attached ss. Also, I have removed the popup window as it was preventing the task from completing.  

 

#Start-Transcript -Path "C:\transcriptPing.txt" -Force

#Add-Type -AssemblyName PresentationCore,PresentationFramework

$names        = Get-content "C:\Servers.txt" #@('192.168.50.1','192.168.50.2','8.8.8.8')#
$subname      = $null
$chequea      = "no"
$dia          = Get-date
#$ButtonType   = [System.Windows.MessageBoxButton]::OK
#$MessageIcon  = [System.Windows.MessageBoxImage]::Error
#$MessageTitle = "Falla de Alcance por Ping"

$ipsV4 = $(Get-NetAdapter -Physical | where status -eq 'up' | Get-NetIPAddress | where{$_.AddressFamily -eq 'IPv4'}).IPAddress 

Foreach($ipV4_tmp in $ipsV4) #added due that multiple Adapter could be up
 {
  $ipV4 = $null
  [System.Net.IPAddress]$ipV4 = $ipV4_tmp
  Write-Host "Local Adapter ip" $ipV4.IPAddressToString -ForegroundColor Cyan

  If($ipV4_tmp)
   {
    if ($ipV4.GetAddressBytes()[0] -eq "192" -and $ipV4.GetAddressBytes()[1]  -eq "168" -and $ipV4.GetAddressBytes()[2] -eq "5" ){
    $chequea="si"
    }
    
    if ($ipV4.GetAddressBytes()[0] -eq "192" -and $ipV4.GetAddressBytes()[1] -eq "168" -and $ipV4.GetAddressBytes()[2] -eq "6" ){
    $chequea="si"
    }
    
    if ($ipV4.GetAddressBytes()[0] -eq "10" -and $ipV4.GetAddressBytes()[1] -eq "212" -and $ipV4.GetAddressBytes()[2] -eq "134" ){
    $chequea="si"
    }
   }
  Else
   {
    Write-Host "Adapter IP item was empty"
   }
 } 

if($chequea -eq "si")
 {
  $Output += "$dia : "
  foreach ($name in $names)
   {
    if(Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue)
     {
    $Output+= "$name ====>> UP || "
    Write-Host "$name ====>> UP "
   }
    else
     {
    $Output+= "$name ====>> DOWN || "
    Write-Host "$name ====>> DOWN "
    #region Conditions
   if($name -eq "8.8.8.8")
    {
     $subname="DNS Google"
    }
   if($name -eq "www.google.com")
    {
     $subname = "Dominio Google"
    }
   if($name -eq "192.168.5.1")
    {
     $subname="Firewall"
    }
   if($name -eq "192.168.5.2")
    {
     $subname="Server 10"
    }
   if($name -eq "192.168.5.30")
    {
     $subname="Server 8"
    }
   if($name -eq "192.168.5.29")
    {
     $subname="Server 9"
    }
   if($name -eq "192.168.5.52")
    {
     $subname="Server 7"
    }
   if($name -eq "192.168.6.16")
    {
     $subname="Server 1"
    }
   if($name -eq "192.168.5.94")
    {
     $subname="Server 2"
    }
   if($name -eq "192.168.5.102")
    {
     $subname="Server 3" 
    }
   if($name -eq "192.168.5.43")
    {
     $subname="Server 4"
    }
   if($name -eq "192.168.5.124")
    {
     $subname="Server 5"
    }
   if($name -eq "192.168.6.250")
    {
    $subname="Impresora Wifi"
    }
   if($name -eq "192.168.5.250")
    {
     $subname="Impresora Xerox "
    }
   #endregion
    #$MessageBody = "Conexion Perdida con el IP: $name, $subname"
    #$oReturn=[System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
    }#If
   }#foreach
   $Output | Out-file "C:\PingResult.txt" -Append
 }#If

  #Stop-Transcript

 
 
Ok, but what solution could be applied to return an alert identifying me the IP and name of the service dropped in this case? since popus cause a problem with the task.

@Erick A. Moreno R. 

 

I'm throwing this error with the code you send me

 

Get-content : No se encuentra la ruta de acceso 'C:\Servers.txt' porque no existe.
En C:\Users\LabsXD-1\Documents\DevOps\checkpingPowershell\CheckPing.ps1: 5 Carácter: 17
+ $names = Get-content "C:\Servers.txt" #@('192.168.50.1','192.1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Servers.txt:String) [Get-Content], ItemNot
FoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

Local Adapter ip 192.168.6.32
Out-file : Acceso denegado a la ruta de acceso 'C:\PingResult.txt'.
En C:\Users\LabsXD-1\Documents\DevOps\checkpingPowershell\CheckPing.ps1: 117 Carácter: 14
+ $Output | Out-file "C:\PingResult.txt" -Append
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (:) [Out-File], UnauthorizedAccessException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand

@Nervill_mcbo For the error: You have to update the location of the server's file as it is looking for C:\servers.txt

The alternatives; Save a file containing all the IPs that did not respond or send an email notifying about it at the end. 

I can help you with that later, just confirm that after modifying the server's file location the script is able to complete using the task scheduler after that we can add functionality to the script as needed.