.NET Framework - BindCommandLineParametersNoValidation for [System.Net.Dns]::Resolve([System.Net.Dns]::GetHostName())

Asked By rferrisx
08-Jul-08 07:49 AM
This works:
[System.Net.Dns]::Resolve([System.Net.Dns]::GetHostName())

and this works also:
$hostnameX =
[System.Net.Dns]::Resolve([System.Net.Dns]::GetHostName())

However, this does not:
function hostnameX
[System.Net.Dns]::Resolve([System.Net.Dns]::GetHostName())

My $StackTrace says:

System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1
arguments)"
System.Net.IPHostEntry
(1)
System.Net.IPAddress
(1)
Windows Server
(1)
IsIPv6LinkLocal
(1)
IsIPv6SiteLocal
(1)
XP
(1)
IsIPv6Multicast
(1)
System.Boolean
(1)
  Marco Shaw [MVP] replied...
07-Jul-08 02:45 PM
PS>get-help about_function
...
function | filter
[<scope_type>:]<name>
{ param()  }
...

I don't see your curlies... ;-)

XP SP2, v2 CTP2, with curlies, that works fine.

Marco

--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
  kum replied...
08-Jul-08 09:12 PM
Also note that [System.Net.Dns]::Resolve() is obsolete as are most of the
static methods of this class.
http://msdn.microsoft.com/en-us/library/system.net.dns_members.aspx  The
recommended alternative is [System.Net.Dns]::GetHostEntry()
  rferrisx replied...
12-Jul-08 01:00 AM
em.net.dns_members.aspx=A0The

Kuma:

Thanks for this information. Could you possibly help me understand why
there are different object names if I pipe my variable to "fl *" than
otherwise? For example below

this won't work:  $hostname_Y.computername
but this will: $hostname_Y.hostname

Also, no "IPAddressToString" method is provided for
[System.Net.Dns]::GetHostEntry()

as is provided for [System.Net.IPAddress]


[System.Net.IPAddress]::Broadcast.IPAddressToString
or
[System.Net.IPAddress]::Loopback.IPAddressToString

Thanks,

Ryan



$hostname_Y =3D [System.Net.Dns]::GetHostEntry("rmfmedia")
$hostname_Y

ComputerName    Aliases         Addresses
------------    -------         ---------
rmfmedia        {}              {192.168.0.5}

$hostname_Y | fl *
HostName    : rmfmedia
Aliases     : {}
AddressList : {192.168.0.5}

$hostname_Y.AddressList


Address         : 83929280
AddressFamily   : InterNetwork
ScopeId         :
IsIPv6Multicast : False
IsIPv6LinkLocal : False
IsIPv6SiteLocal : False
  Kuma replied...
16-Jul-08 01:16 AM
When you pipe it to format-list it changes the object type. Probably
for formatting it to display it on the screen.

PoSh [14] =BB ([System.Net.DNS]::GetHostEntry("computer")).Gettype()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     False    IPHostEntry
System.Object


PoSh [15] =BB ([System.Net.DNS]::GetHostEntry("computer")| fl
*).Gettype()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Object[]
System.Array


Thats because GetHostEntry() returns an IPHostEntry which contains a
collection of IPAddress objects in its AddressList collection. The
informations is still there just buried a little bit.

PoSh [22] =BB [System.Net.DNS]::GetHostEntry("computer")

HostName
Aliases                                 AddressList
--------
-------                                 -----------
computer.windows.nobody.nowhere.com
{}                                      {12.12.12.12}


PoSh [23] =BB ([System.Net.DNS]::GetHostEntry("computer")).AddressList


IPAddressToString : 12.12.12.12
Address           : 4583216589
AddressFamily     : InterNetwork
ScopeId           :
IsIPv6Multicast   : False
IsIPv6LinkLocal   : False
IsIPv6SiteLocal   : False



PoSh [24]
=BB ([System.Net.DNS]::GetHostEntry("computer")).AddressList[0].IPAddressTo=
String
12.12.12.12

Hope that helps clear stuff up a bit. Remember to use Get-Member to
see what properties, methods, type of object etc exist on an item. Its
helped me a lot.

PoSh [31] =BB [System.Net.DNS]::Resolve("computer") | Get-Member


TypeName: System.Net.IPHostEntry

Name            MemberType Definition
----            ---------- ----------
Equals          Method     System.Boolean Equals(Object obj)
GetHashCode     Method     System.Int32 GetHashCode()
GetType         Method     System.Type GetType()
get_AddressList Method     System.Net.IPAddress[] get_AddressList()
get_Aliases     Method     System.String[] get_Aliases()
get_HostName    Method     System.String get_HostName()
set_AddressList Method     System.Void set_AddressList(IPAddress[]
value)
set_Aliases     Method     System.Void set_Aliases(String[] value)
set_HostName    Method     System.Void set_HostName(String value)
ToString        Method     System.String ToString()
AddressList     Property   System.Net.IPAddress[] AddressList
{get;set;}
Aliases         Property   System.String[] Aliases {get;set;}
HostName        Property   System.String HostName {get;set;}
Create New Account
help
ContentAlignment (1) GraphicsUnit (1) EventHandler (1) FontStyle (1) CheckBox (1) TextBox (1) Is this a Windows Forms application? If so, there ishould be a region titled is not totally packed with InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InvoiceForm)); this.textBox17 = new System.Windows.Forms.TextBox(); this.textBox15 = new System.Windows.Forms.TextBox(); this.textBox7 = new System.Windows.Forms.TextBox(); this.textBox6 = new System.Windows.Forms.TextBox(); this.textBox5 = new System.Windows.Forms.TextBox(); this.textBox4 = new System Windows.Forms.TextBox(); this.textBox3 = new System.Windows.Forms.TextBox(); this.textBox2 = new System.Windows.Forms.TextBox(); this.textBox1 = new System.Windows.Forms
doch so gut wie keinen Spam. Schade! MfG Susann VB - German Discussions Microsoft Word (1) Windows Server (1) Windows Vista (1) STUDIO one (1) Outlook (1) Office (1) Linux (1) Excel (1) Hallo, *Susann den von ihm gehaltenen Hirachie die RM-Groups bzw. die Checkgroups fuer die auf seinem Server zugelassenen Gruppen nachzuvollziehen. Je nach Admin dauert das mal kuerzer oder mal laenger. Google laesst da schon mal ein paar Monate Zeit. Es werden sich aber mit Sicherheit auch noch Server finden lassen, die msnews.* noch in ein paar Jahren zur Verfuegung stellen. ;-) Wer Newsgroups vorzieht über alle Newsgroups laufen und aktualisiert werden. Wenn wenig 'traffic' ist, dann ist auch die Server-Belastung sehr gering. Also, was soll's? - - Thorsten Albers albers (a) uni-freiburg.de Harald w?rde der "unbedarfte" Benutzer gar nichts davon mitbekommen, da? unter der Haube ein NNTP-Server arbeitet. - - M S Herfried K. Wagner M V P <URL:http: / / dotnet.mvps.org / > V von mir regelmässig besuchten Enwickler-NGs jedenfalls sehr ausgiebig. Ich lese auch regelmässig die div. Windows-NGs und muss zugeben, dass es dort einige sog. "Experten" gibt, bei denen ich manchmal
Timeout expired. The timeout period elapsed prior to completion ofthe operation or the server is not responding. .NET Framework Our application is in VB.NET 2008 and our database is SQL Server 2005. Our application runs on Windows Server 2003 R2 Standard Edition SP 2. The database runs on Windows Server 2003 R2 Enterprise x64 Edition SP 1. The database server has many databases. The database connection string in the program uses a name instance, not error "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding." What would cause this error to show up every now and then
View timed out every now and then .NET Framework We are using SQL Server 2005 and VB.NET 2008. We have a view that is called by the application of 2 more views and a table. When I run the view on the SQL Server Management Studio, it runs for 2 seconds. Most of the time when the view is error "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.), even after I set the command time out to 45 seconds (which runs fast most of the time, but very slow once or twice a day ? SQL Server machine has 8 processors of 2993 Mhz each and 32 MB of RAM. Right now the available physical memory there is 18.48 GB, and SQL Server is using 9-50% of CPU and 11, 358, 080K of RAM. It has 32 IDbCommand command, CommandBehavior behavior) System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) VB.NET Discussions SQL Server 2000 (1) SQL Server 2005 (1) BulkCopySimpleResultSet (1) SQL Server Management Studio (1) SQL Server Books Online (1) TdsParserStateObject (1) SqlDataAdapter (1) DbAsyncResult (1) fniles
14:56, schrieb Roidy: Try this: (passing "NAS") System.Net.Dns.GetHostByName(ByVal String) As System.Net.IPHostEntry Does it fail, too? - - Armin Thanks Armin, VB complains that GetHostByName is obsolete and tells you to use GetHostEntry, which works perfectly:- Dim hostname As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry("NAS") Dim ipaddress() As System.Net.IPAddress = hostname.AddressList Now it just an easy task to write a function to strip