Display: Cloud | List
Most Popular Tags
Results (5 total) All > system.net (x)
A simple PowerShell example of using the Parse method of the PhysicalAddress class (PhysicalAddress.Parse Method (System.Net.NetworkInformation))
$IPAddress = '10.10.10.1'Write-Host 'Test that the IP address works' $IP = Test-Connection -ComputerName $IPAddress -Count 1 -ErrorAction StopWrite-Host 'Get the mac address from arp'$Mac = (% arp -a $IP.Address)Write-Host 'Regex the output of Arp to get the mac address' $MacAddress = ($mac | ? { $_ -match $IP.Address } ) -match "([0-9A-F]{2}([:-][0-9A-F]{2}){5})"if ($Matches){ try {
Last modified by Thomas Lee on 4/29/2012 1:04:35 PM
Tags:  code  powershell  system.net
NetworkAccess ENUM usingPowerShell (NetworkAccess Enumeration (System.Net))
# enum-NetworkAccess.ps1# Demonstrates the NetworkAccess enum# Thomas Lee - tfl@psp.co.uk # Get Enum values and display $enums=[enum]::GetValues([System.Net.NetworkAccess])"System.Net.NetworkAccess enum has {0} possible values" -f $enums.count$i=1$enums|%{"Value {0}: {1}" -f $i,$_.tostring();$i++}"" # Checking against a an enum value $ToCheck1 = "somethingelse"$tocheck2 = "Accept" if ($ToCh
Last modified by Thomas Lee on 10/29/2008 5:44:48 PM
Tags:  code  powershell  system.net
Host Not Found Errors (HttpWebRequest.Proxy Property (System.Net))
Do you have WebRequest code that works great in a console application, but gives "Host Not Found" exception errors when run in IIS? Are you running in an environment behind a firewall? If so almost certainly need to set a proxy for your connections either in code or configuration. "Host Not Found" is the classic exception for this situation - but it may manifest itself in other forms e.g. "Canno
Last modified by Steve Butler MSFT on 5/13/2008 7:57:43 PM
.NET Framework Class LibraryHttpWebRequest..::.Proxy Property HttpWebRequest ClassGets or sets proxy information for the request.Namespace:  System.NetAssembly:  System (in System.dll)SyntaxVisual Basic (Declaration)Public Overrides Property Proxy As IWebProxyVisual Basic (Usage)Dim instance As HttpWebRequest Dim value As IWebProxy value = instance.Proxy instance.Proxy = valueC#publi
Last modified by Microsoft on 5/8/2008 2:20:44 AM
Sample - converted to PowerShell (WebClient Class (System.Net))
# webclient.ps1# Web client sample recoded in PowerShell# Converted from MSDN C# Sample# Thomas Lee - tfl@psp.co.uk# get a web page (author's blog)$client = new-object system.net.WebClient$client.Headers.Add("user-agent", "PowerShell")$data = $client.OpenRead("http://tfl09.blogspot.com/")$reader = new-object system.io.StreamReader $data [string] $s = $reader.ReadToEnd() # display output"The ret
Last modified by Thomas Lee on 7/30/2011 9:22:40 PM
Tags:  code  powershell  system.net
Page view tracker