Monday, 25 May 2009

Get-RegionInfo

  1. <# 
  2. .SYNOPSIS 
  3.     This script displaysthe property values for a globlisation region 
  4. .DESCRIPTION 
  5.     This script 
  6. .NOTES 
  7.     File Name  : Get-RegionInfo.ps1 
  8.     Author     : Thomas Lee - tfl@psp.co.uk 
  9.     Requires   : PowerShell V2 CTP3 
  10. .LINK 
  11.     This script posted to: 
  12.         http://www.pshscripts.blogspot.com 
  13.     MSDN Sample posted at: 
  14.         http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.aspx 
  15. .EXAMPLE 
  16.     PSH [C:\foo]: .\Get-RegionInfo.ps1' 
  17.     Name:                         US 
  18.     DisplayName:                  United States 
  19.     EnglishName:                  United States 
  20.     IsMetric:                     False 
  21.     ThreeLetterISORegionName:     USA 
  22.     ThreeLetterWindowsRegionName: USA 
  23.     TwoLetterISORegionName:       US 
  24.     CurrencySymbol:               $ 
  25.     ISOCurrencySymbol:            USD 
  26.  
  27.    The two RegionInfo instances are equal. 
  28.      
  29. #> 
  30.   
  31. ## 
  32. # start of script 
  33. ## 
  34.   
  35. # greate a region 
  36.  
  37. $myRI1 = New-Object System.Globalization.RegionInfo "US"  
  38. "   Name:                         {0}" -f $myRI1.Name 
  39. "   DisplayName:                  {0}" -f $myRI1.DisplayName 
  40. "   EnglishName:                  {0}" -f $myRI1.EnglishName 
  41. "   IsMetric:                     {0}" -f $myRI1.IsMetric 
  42. "   ThreeLetterISORegionName:     {0}" -f $myRI1.ThreeLetterISORegionName 
  43. "   ThreeLetterWindowsRegionName: {0}" -f $myRI1.ThreeLetterWindowsRegionName 
  44. "   TwoLetterISORegionName:       {0}" -f $myRI1.TwoLetterISORegionName  
  45. "   CurrencySymbol:               {0}" -f $myRI1.CurrencySymbol  
  46. "   ISOCurrencySymbol:            {0}" -f $myRI1.ISOCurrencySymbol  
  47. "" 
  48.  
  49. # Compare the RegionInfo above with another RegionInfo created using CultureInfo 
  50. $culinfo = New-Object system.Globalization.CultureInfo "en-us", $false 
  51. $myRI2   = New-Object System.Globalization.RegionInfo $culinfo.lcid 
  52.  if ( $myRI1.Equals( $myRI2 )) { 
  53.    "The two RegionInfo instances are equal." 
  54. else
  55.    "The two RegionInfo instances are NOT equal." 
  56.     

Saturday, 23 May 2009

Get-FileVersionInfo.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script gets and displays the file version information of a file 
  4. .DESCRIPTION 
  5.     This script calls System.Diagnostics.FileVersionInfo's  
  6.     GetVersion info method on the file. By default, the file version 
  7.     displayed/returned is that of %systemroot%\notepad.exe.  
  8. .NOTES 
  9.     File Name  : Get-FileVersionInfo.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell V2 CTP3 
  12.     Note       : The file named passed to GetVersionInfo needs to  
  13.                  be fully qualified, not just local name. 
  14. .LINK 
  15.     This script posted to: 
  16.       http://www.pshscripts.blogspot.com 
  17.     MSDN Sample posted at: 
  18.       http://msdn.microsoft.com/en-us/library/system.diagnostics.fileversioninfo.aspx 
  19. .EXAMPLE 
  20.     PSH [C:\foo]: .\Get-FileVersionInfo.ps1 
  21.     File Description : Notepad 
  22.     File Version     : 6.0.6000.16386 (vista_rtm.061101-2205) 
  23. .EXAMPLE 
  24.     PSH [C:\Foo]: .\Get-FileVersionInfo.ps1' c:\windows\fveupdate.exe 
  25.     File Description : BitLocker Drive Encryption Servicing Utility 
  26.     File Version     : 6.0.6000.16386 (vista_rtm.061101-2205) 
  27. .PARAMETER filename 
  28.     The name of the file for which file version information is displayed. 
  29. #> 
  30.  
  31. param
  32. [string] $filename = $(join-path ${env:systemroot} "Notepad.Exe"
  33.  
  34. ## 
  35. # start of script 
  36. ## 
  37.  
  38. $info= [system.Diagnostics.FileVersionInfo]::GetVersionInfo($filename
  39. "File Description : {0}" -f  $info.filedescription 
  40. "File Version     : {0}" -f  $info.fileversion 
  41.   

Tuesday, 19 May 2009

Get-XMLFileContents.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script reads a simple XML file and prints the results 
  4. .DESCRIPTION 
  5.     This script is a re-write of an XML C# MSDN Sample. 
  6. .NOTES 
  7.     File Name  : get-xmlfilecontents.ps1 
  8.     Author     : Thomas Lee - tfl@psp.co.uk 
  9.     Requires   : PowerShell V2 CTP3 
  10.     Books3.xml =  
  11.       <book> 
  12.       <title>C# Introduction</title> 
  13.       <price>20</price> 
  14.       </book> 
  15. .LINK 
  16.     This script posted to: 
  17.         http://www.pshscripts.blogspot.com 
  18.     MSDN Sample posted at: 
  19.         http://msdn.microsoft.com/en-us/library/t9bfea29.aspx 
  20. .EXAMPLE 
  21.     PSH [C:\foo]: .\Get-XMLFileContents.PS1 
  22.     The content of the title element: C# Introduction 
  23.     The content of the price element: 20 
  24.   
  25. #> 
  26.   
  27. ## 
  28. # Start of Script 
  29. ## 
  30.   
  31. # Create XML Reader 
  32. $reader = [system.Xml.XmlReader]::Create("C:\foo\book3.xml"
  33.   
  34. # Parse the XML document.  ReadString is used to  
  35. # read the text content of the elements. 
  36. $result=$reader.Read() 
  37.   
  38. # Read/Display title 
  39. $reader.ReadStartElement("book"
  40. $reader.ReadStartElement("title")    
  41. "The content of the title element: {0}" -f $reader.ReadString() 
  42. $reader.ReadEndElement() 
  43.   
  44. # Read and display price 
  45. $reader.ReadStartElement("price"
  46. "The content of the price element: {0}" -f $reader.ReadString() 
  47. $reader.ReadEndElement() 
  48. $reader.ReadEndElement() 
  49. # End of Script 

Wednesday, 6 May 2009

Get-ElapsedTime.ps1

  1. <#  
  2. .SYNOPSIS  
  3.     Demonstrates use of the System.Diagnostics.Stopwatch .NET Class    
  4. .DESCRIPTION  
  5.     This script is a community content MSDN sample,using PowerShell  
  6. .NOTES  
  7.     File Name  : Get-ElapsedTime 
  8.     Author     : Thomas Lee - tfl@psp.co.uk  
  9.     Requires   : PowerShell V2 CTP3  
  10. .LINK  
  11.     Sample posted to:  
  12.     http://pshscripts.blogspot.com  
  13.     Original MSDN sample at:  
  14.     http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx 
  15. .EXAMPLE  
  16.     PSH [C:\foo]: .\get-stopwatch.ps1' 
  17.     Runtime = 00:00:10.03 
  18.  
  19. #>  
  20.  
  21. ## 
  22. # start of script 
  23. ## 
  24.  
  25. # Create a new stopwatch objecty 
  26. $StopWatch = New-Object system.Diagnostics.Stopwatch 
  27.   
  28. # Start the stop watch 
  29. $stopWatch.Start() 
  30.  
  31. # Go to sleep for approx 10 seconds 
  32. [system.threading.Thread]::Sleep(10000) 
  33.  
  34. # Now after sleep, stop the watch 
  35. $StopWatch.Stop(); 
  36.  
  37. # Get the elapsed time as a TimeSpan value. 
  38. $ts = $StopWatch.Elapsed 
  39.  
  40. # Format and display the TimeSpan value. 
  41. $ElapsedTime = [system.String]::Format("{0:00}:{1:00}:{2:00}.{3:00}"
  42.            $ts.Hours, $ts.Minutes, $ts.Seconds, 
  43.             $ts.Milliseconds / 10); 
  44. "Runtime = $elapsedTime" 

Tuesday, 5 May 2009

Clear-Stopwatch.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script displays the use of the Reset method in a StopWatch object. 
  4. .DESCRIPTION 
  5.     This script calls the StartNew static method to create and start a new  
  6.     stopwatch object, and displays the current values for the stop watch. The  
  7.     stopwatch is then reset using the Reset method, then the current values are displayed.  At completion, 
  8.     the stopwatch is stopped and all counters are zero. 
  9. .NOTES 
  10.     File Name  : Clear-Stopwatch.ps1 
  11.     Author     : Thomas Lee - tfl@psp.co.uk 
  12.     Requires   : PowerShell V2 CTP3 
  13. .LINK 
  14.     This script posted to: 
  15.         http://www.pshscripts.blogspot.com 
  16.     MSDN Sample posted at: 
  17.         http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.reset.aspx 
  18. .EXAMPLE 
  19.     PSH [C:\foo]: .\Clear-Stopwatch.ps1 
  20.     StopWatch object before reset: 
  21.     IsRunning           : True 
  22.     Elapsed             : 00:00:00.0039085 
  23.     ElapsedMilliseconds : 3 
  24.     ElapsedTicks        : 57153 
  25.     StopWatch object after reset: 
  26.     IsRunning           : False 
  27.     Elapsed             : 00:00:00 
  28.     ElapsedMilliseconds : 0 
  29.     ElapsedTicks        : 0 
  30. #> 
  31.    
  32. ## 
  33. #  Begin script 
  34. ## 
  35. # Create a stop watch object and auto start it 
  36. $sw = [system.Diagnostics.Stopwatch]::StartNew() 
  37.    
  38. # Now get current elapsed time: 
  39. "StopWatch object before reset:" 
  40. $sw | fl * 
  41.    
  42. # Now reset 
  43. $sw.reset() 
  44.    
  45. # Observe Results 
  46. "StopWatch object after reset:" 
  47. $sw | fl * 
  48. # End script 

Monday, 4 May 2009

Get-LegalInfo.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     Gets LegalCopyright and Legal Trademarks from a file, if they exist. 
  4. .DESCRIPTION 
  5.     This script uses System.Diagnostic.FileVersionInfo to get the version information 
  6.     of a file. in this sample, I use notepad.exe, as shipped with Windows. 
  7.    
  8.     If you look at the output, you see LegalTrademarks are empty - this is the result I get on my 
  9.     main workstation.  
  10. .NOTES 
  11.     File Name  : Get-LegalInfo.ps1 
  12.     Author     : Thomas Lee - tfl@psp.co.uk 
  13.     Requires   : PowerShell V2 CTP3 
  14. .LINK 
  15.     http://www.pshscripts.blogspot.com 
  16. .EXAMPLE 
  17.     PSH [C:\foo]: .\Get-LegalInfo.ps1 
  18.     LegalCopyright  :  c Microsoft Corporation. All rights reserved. 
  19.     Legal Trademarks: 
  20. #> 
  21. ## 
  22. # start of script 
  23. ## 
  24.   
  25. # Get the file version for the notepad. 
  26. $MyFileVersionInfo = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\windows\Notepad.exe"
  27.   
  28. # Now output legal Information 
  29. "LegalCopyright  :  {0}" -f $MyFileVersionInfo.LegalCopyright 
  30. "Legal Trademarks:  {0}" -f $myFileVersionInfo.LegalTrademarks 
  31. # End of Script 

Saturday, 2 May 2009

Get-StopWatchProperties.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     Gets and displays properties of a stopwatch 
  4. .DESCRIPTION 
  5.     This script, written as an MSDN Sample, creates and starts a stop watch. The 
  6.     script stops the stopwatch, and displays the properties. To some degree, the  
  7.     results indicate how long it takes to start and stop a stopwatch. Also, the 
  8.     runtimes vary if you run it multiple times.  
  9. .NOTES 
  10.     File Name  : Get-StopWatchProperties.ps1 
  11.     Author     : Thomas Lee - tfl@psp.co.uk 
  12.     Requires   : PowerShell V2 CTP3 
  13. .LINK
  14.     Original sample posted at: http://pshscripts.blogspot.com/2009/05/get-stopwatchpropertiesps1.html
  15.     MSDN Sample posted at: http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch_properties.aspx  
  16. .EXAMPLE 
  17.     PSH [C:\foo]: .\Get-StopWatchProperties.PS1' 
  18.     IsRunning           : False 
  19.     Elapsed             : 00:00:00.0000162 
  20.     ElapsedMilliseconds : 0 
  21.     ElapsedTicks        : 233 
  22.   
  23. #> 
  24.   
  25. ## 
  26. # Start of script 
  27. # 
  28.    
  29. # Create and start a stopwatch 
  30.    
  31. $StopWatch = New-Object System.Diagnostics.Stopwatch 
  32.   
  33. # Now start, then stop, the stopwatch 
  34. $StopWatch.start() 
  35. $StopWatch.stop() 
  36.    
  37. # Display results 
  38.    
  39. $stopwatch | Format-List
  40. # End of Script 

Tuesday, 21 April 2009

Get-PrinterTestPage.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script uses WMI to print a test page 
  4.     all printers on this system 
  5. .DESCRIPTION 
  6.     This script is an MSDN sample,using PowerShell. It first 
  7.     gets all the printrs installed, prints out details then 
  8.     tries to print a test page. 
  9.      
  10.     The script also checks for printers known to not work well, and avoids using them 
  11. .NOTES 
  12.     File Name  : Get-PrinterTestPage.ps1 
  13.     Author     : Thomas Lee - tfl@psp.co.uk 
  14.     Requires   : PowerShell V2 CTP3 
  15. .LINK 
  16.     Sample posted to: 
  17.         http://pshscripts.blogspot.com/2009/04/get-printertestpageps1.html
  18.     Original MSDN sample at: 
  19.         http://msdn.microsoft.com/en-us/library/aa392757(VS.85).aspx  
  20. .EXAMPLE 
  21.     PSH [C:\foo]: .Get-PrinterTestPage.ps1' 
  22.     4 Printers defined on this system 
  23.     Printer share name: \ 
  24.     Printer Port      : C:\ProgramData\TechSmith\SnagIt 9\PrinterPortFile 
  25.     Printer share name: \Phaser PS 
  26.     Printer Port      : X_10.10.1.117 
  27.     Printer share name: \ 
  28.     Printer Port      : XPSPort: 
  29.     Printer share name: \\SLT-PC\officejet 
  30.     Printer Port      : USB002 
  31.      
  32.     Printing test page for printer: SnagIt 9 
  33.     Not printing a test page for this printer 
  34.     Printing test page for printer: Phaser PS 
  35.     Result                        : 0 
  36.     Printing test page for printer: Microsoft XPS Document Writer 
  37.     Not printing a test page for this printer 
  38.     Printing test page for printer: \\JerryGarcia\HP Officejet Pro L7400 Series 
  39.     Result                        : 0 
  40.     #> 
  41.  
  42. ### 
  43. # Start of Script 
  44. ### 
  45.   
  46. # Get Printer Objects for this computer from WMI 
  47. $printers = Get-WmiObject -Class Win32_Printer 
  48. # Display printers 
  49. "{0} Printers defined on this system" -f $printers.count 
  50.  
  51. # For printers, display printer details 
  52. foreach ($printer in $printers) { 
  53. "Printer share name: {0}\{1}" -f $printer.servername, $printer.sharename 
  54. "Printer Port      : {0}    " -f $printer.PortName   
  55. "" 
  56.  
  57. # Now Print a test page for each printer 
  58. foreach ($printer in $printers) { 
  59. "Printing test page for printer: {0}" -f $printer.name 
  60.  
  61. # avoid issue with Known bad printers
  62. if ($printer.DriverName -match "XPS" -or $printer.DriverName -match "SnagIt")  { 
  63. "Not printing a test page for this printer" 
  64. else
  65. $Result = $printer.PrintTestPage() 
  66. "Result                        : {0}" -f $Result.ReturnValue 
  67. # End of script 
Technorati Tags: ,,,

Win32_Fan Sample using PowerShell

  1. <# 
  2. .SYNOPSIS 
  3.     Uses Win32_Fan class to return information about fans in a system.     
  4. .DESCRIPTION 
  5.     This script first defines some functions to decode various  
  6.     WMI attributed from binary to text. Then the script calls  
  7.     Get-WmiObject to retrieve fan details, then formats that 
  8.     information (using the functions defined at the top of the script. 
  9.      
  10. .NOTES 
  11.     File Name  : Get-Fan.ps1 
  12.     Author     : Thomas Lee - tfl@psp.co.uk 
  13.     Requires   : PowerShell V2 CTP3 
  14. .LINK 
  15.     Script posted to: 
  16.     http://pshscripts.blogspot.com/2009/04/win32fan-sample-using-powershell.html
  17.     Original MSDN Page 
  18.     http://msdn.microsoft.com/en-us/library/aa394146(VS.85).aspx 
  19. .EXAMPLE 
  20.     Left as an exercise for the viewer.     
  21. #> 
  22.  
  23. ### 
  24. # Start of Script 
  25. ### 
  26.  
  27. # Functions to decode details 
  28.  
  29. function FanAvailability { 
  30. param ($value
  31. switch ($value) { 
  32. 1    {"Other"
  33. 2    {"Unknown"
  34. 3    {"Running on full power"
  35. 4    {"Warning"
  36. 5    {"In Test"
  37. 6    {"Not Applicable"
  38. 7    {"Power Off"
  39. 8    {"Off Line"
  40. 9    {"Off Duty"
  41. 10   {"Degraded"
  42. 11   {"Not Installed"
  43. 12   {"Install Error"
  44. 13   {"Power Save - Unknown"
  45. 14   {"Power Save - Low Power Mode"
  46. 15   {"Power Save - Standby"
  47. 16   {"Power Cycle"
  48. 17   {"Power Save - Warning"
  49. default {"NOT SET"
  50.  
  51. function ConfigManagerErrorCode { 
  52. param ($value
  53. switch ($value) { 
  54. 0 {"Device Is Working Properly"
  55. 1 {"Device is not configured correctly"
  56. 2 {"Windows Cannot load the driver for this device"
  57. 3 {"Driver for this device might be corrupted, or the system may be low on memory or other resources"
  58. 4 {"Device is not working properly. One of its drivers or the registry might be corrupted"
  59. 5 {"Driver for the device requires a resource that Windows cannot manage"
  60. 6 {"Boot configuration for the device conflicts with other devices"
  61. 7 {"Cannot filter"
  62. 8 {"Driver loader for the device is missing"
  63. 9 {"Device is not working properly. The controlling firmware is incorrectly reporting the resources for the device"
  64. 10 {"Device cannot start"
  65. 11 {"Device failed"
  66. 12 {"Device cannot fine enough free resources to run"
  67. 13 {"Windows cannot verify the devices's resources"
  68. 14 {"Device cannot work propertly until the computer is restarted"
  69. 15 {"Device is not working properly due to a possible re-enumeration problem"
  70. 16 {"Windows cannot identify all of the resources that the device uses"
  71. 17 {"Device is requesting an unknown resource type"
  72. 18 {"Device drivers must be reinstalled"
  73. 19 {"Failure using the VxD loader"
  74. 20 {"Registry might be corrupted"
  75. 21 {"System failure. if changing the device driver is ineffective, see the hardware documentation. Windows is removing the device"
  76. 22 {"Device is disabled"
  77. 23 {"System failure. if changing the device driver is ineffective, see the hardware documentation"
  78. 24 {"Device is not present, not working properly, or does not have all of its drivers installed"
  79. 25 {"Windows is still setting up the device"
  80. 26 {"Windows is still setting up the device"}  
  81. 27 {"Device does not have valid log configuration"
  82. 28 {"Device drivers are not installed"
  83. 29 {"Device is disabled. The device firmware did not provide the required resources"
  84. 30 {"Device is using an IRQ resource that another device is using"
  85. 31 {"Device is not working properly. Windows cannot load the required device drivers."
  86. default {"NOT SET"
  87.  
  88. function PowerManagementCapabilities { 
  89. param ($value
  90. switch ($value) { 
  91. 0 {"Unknown"
  92. 1 {"Not Supported"
  93. 2 {"Disabled"
  94. 3 {"Enabled"
  95. 4 {"Power Saving Modes Entered Automatically"
  96. 5 {"Power State Settable"
  97. 6 {"Power Cycling Supported"
  98. 7 {"Timed Power-On Supported"
  99. default {"NOT SET"
  100. }  
  101.  
  102. function StatusInfo { 
  103. param ($value
  104. switch ($value) { 
  105. 0 {"Other"
  106. 2 {"Unknown"
  107. 3 {"Enabled"
  108. 4 {"Disabled"
  109. 5 {"Not Applicable"
  110. default {"NOT SET"
  111.  
  112. ### 
  113. # Start of Script 
  114. ## 
  115.  
  116. # Get fan information 
  117. $fans = Get-WmiObject -Class Win32_Fan 
  118.  
  119. # Display information 
  120. $hostnm=hostname 
  121. "Fan Information on System: {0} ({1} fans in total" -f $hostnm, $fans.count 
  122. $i=1 
  123. # display details of each fan 
  124. foreach ($fan in $fans) { 
  125. # Display details 
  126. "Fan: {0}"  -f $i 
  127. "Active Cooling                : {0}" -f $fan.ActiveCooling 
  128. "Availability                  : {0}" -f (fanavailability($fan.availability)) 
  129. "Caption                       : {0}" -f $fan.caption 
  130. "Config Manager Error code     : {0}" -f (ConfigManagerErrorCode($fan.ConfigManagerErrorCode)) 
  131. "Config Manager User Config    : {0}" -f $fan.ConfigManagerUserConfig 
  132. "Creation Class Name           : {0}" -f $fan.CreationClassName 
  133. "Description                   : {0}" -f $fan.Description 
  134. "Desired speed                 : {0}" -f $fan.DesiredSpeed 
  135. "Error Cleared                 : {0}" -f $fan.ErrorCleared 
  136. "Error Description             : {0}" -f $fan.ErrorDescription 
  137. "Install Date                  : {0}" -f $fan.InstallDate 
  138. "Last Error code               : {0}" -f $fan.LastErrorCode 
  139. "Name                          : {0}" -f $fan.name 
  140. "PNP Device Id                 : {0}" -f $fan.PNPDeviceID 
  141. "Power Management Capabilities : {0}" -f (PowerManagementCapabilities($fan.PowerManagementCapabilities)) 
  142. "Status                        : {0}" -f $fan.Status 
  143. "Status Information            : {0}" -f (statusinfo($fan.StatusInfo)) 
  144. "System Creation Class Name    : {0}" -f $fan.syu 
  145. "System Name                   : {0}" -f $fan.SystemName 
  146. "Variable Speed                : {0}" -f $fan.VariableSpeed 
  147.  
  148. $i++;"" 
Technorati Tags: ,,

Sunday, 19 April 2009

Get-HostEntry.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     Demonstrates use of the GetHostEntry method of System.Net.DNS Class 
  4. .DESCRIPTION 
  5.     This script is a an MSDN sample, using PowerShell 
  6. .NOTES 
  7.     File Name  : Get-HostEntry.ps1 
  8.     Author     : Thomas Lee - tfl@psp.co.uk 
  9.     Requires   : PowerShell V2 CTP3 
  10. .LINK 
  11.     Sample posted to: 
  12.     http://pshscripts.blogspot.com/2009/04/get-hostentryps1.html 
  13.     Original MSDN sample at: 
  14.     http://msdn.microsoft.com/en-us/library/system.net.dns.gethostentry.aspx  
  15. .EXAMPLE 
  16.     PSH [C:\foo]: .\Get-HostEntry.ps1 Cookham8
  17.     Host Name    : Cookham8.cookham.net 
  18.     Alias        : 
  19.     Address      : fe80::d8ed:afe2:2a97:a596%14 
  20.     Address      : fe80::3953:f67b:2f1c:1323%10 
  21.     Address      : 10.10.1.120 
  22.     Address      : 10.10.1.115 
  23. .PARAM HostName 
  24.     The name of the host to search for - the default is "localhost" 
  25. #> 
  26.  
  27. param
  28. [string] $HostName = "localhost" 
  29.  
  30. ### 
  31. # Start of Script 
  32. ### 
  33.   
  34. #Get Host details 
  35.  
  36. $hostentrydetails = [System.Net.Dns]::GetHostEntry($hostname
  37.  
  38. # Print details: 
  39. "Host Name    : {0}" -f $hostentrydetails.HostName 
  40. foreach ($alias in $hostentrydetails.alises) { 
  41. "Alias        : {0}" -f $alias 
  42. foreach ($addr in $hostentrydetails.addresslist) { 
  43. "Address      : {0}" -f $Addr.ipaddresstostring 
  44.   
  45. # End of script