- <#
- .SYNOPSIS
- Demonstrates use of the GetHostEntry method of System.Net.DNS Class
- .DESCRIPTION
- This script is a an MSDN sample, using PowerShell
- .NOTES
- File Name : Get-HostEntry.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- Sample posted to:
- http://pshscripts.blogspot.com/2009/04/get-hostentryps1.html
- Original MSDN sample at:
- http://msdn.microsoft.com/en-us/library/system.net.dns.gethostentry.aspx
- .EXAMPLE
- PSH [C:\foo]: .\Get-HostEntry.ps1 Cookham8
- Host Name : Cookham8.cookham.net
- Alias :
- Address : fe80::d8ed:afe2:2a97:a596%14
- Address : fe80::3953:f67b:2f1c:1323%10
- Address : 10.10.1.120
- Address : 10.10.1.115
- .PARAM HostName
- The name of the host to search for - the default is "localhost"
- #>
- param (
- [string] $HostName = "localhost"
- )
- ###
- # Start of Script
- ###
- #Get Host details
- $hostentrydetails = [System.Net.Dns]::GetHostEntry($hostname)
- # Print details:
- "Host Name : {0}" -f $hostentrydetails.HostName
- foreach ($alias in $hostentrydetails.alises) {
- "Alias : {0}" -f $alias
- }
- foreach ($addr in $hostentrydetails.addresslist) {
- "Address : {0}" -f $Addr.ipaddresstostring
- }
- # End of script
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Sunday 19 April 2009
Get-HostEntry.ps1
Subscribe to:
Post Comments (Atom)
4 comments:
hello sir
i have PS v2 (CPT.)
but Get-HostEntry.ps1 is not run ?
do you way?
tnx for help
arnold
The term 'param' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.
à :ligne:27 caractère:5
+ param <<<< ( '''
Arnold,
Do you have CTP3 loaded? I think that might be your trouble.
How did you get the script onto your system? Did you get it from th ZIP file?
For what it is worth, this works fine here.
Hi thomas :)
Nice to see you.
Yep, i have CPT3,(i loos the 3 befor) is loadet
and i dont see any zypfile :(
only i make copy/past to
importet the file to PowerGUI.
I find you with google :
"powershell convert rssfeed to html"
"PoSh Automaten Host"
Tnx for you answear
arnold
Arnold - the script works fine here. I suspect you may have gotten some garbage characters when you copied over the script.
Try downloading the entire script library from http://www.reskit.net/powershell/ScriptLib.ZIP. It's only just over 100k, and has all the scripts. Try that and let me know.
And for more help email me at doctordns {at} gmail {dot} com.
Post a Comment