- <
- .SYNOPSIS
- This script displaysthe property values for a globlisation region
- .DESCRIPTION
- This script
- .NOTES
- File Name : Get-RegionInfo.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN Sample posted at:
- http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.aspx
- .EXAMPLE
- PSH [C:\foo]: .\Get-RegionInfo.ps1'
- Name: US
- DisplayName: United States
- EnglishName: United States
- IsMetric: False
- ThreeLetterISORegionName: USA
- ThreeLetterWindowsRegionName: USA
- TwoLetterISORegionName: US
- CurrencySymbol: $
- ISOCurrencySymbol: USD
-
- The two RegionInfo instances are equal.
-
-
-
-
-
-
-
-
-
- $myRI1 = New-Object System.Globalization.RegionInfo "US"
- " Name: {0}" -f $myRI1.Name
- " DisplayName: {0}" -f $myRI1.DisplayName
- " EnglishName: {0}" -f $myRI1.EnglishName
- " IsMetric: {0}" -f $myRI1.IsMetric
- " ThreeLetterISORegionName: {0}" -f $myRI1.ThreeLetterISORegionName
- " ThreeLetterWindowsRegionName: {0}" -f $myRI1.ThreeLetterWindowsRegionName
- " TwoLetterISORegionName: {0}" -f $myRI1.TwoLetterISORegionName
- " CurrencySymbol: {0}" -f $myRI1.CurrencySymbol
- " ISOCurrencySymbol: {0}" -f $myRI1.ISOCurrencySymbol
- ""
-
-
- $culinfo = New-Object system.Globalization.CultureInfo "en-us", $false
- $myRI2 = New-Object System.Globalization.RegionInfo $culinfo.lcid
- if ( $myRI1.Equals( $myRI2 )) {
- "The two RegionInfo instances are equal."
- }
- else {
- "The two RegionInfo instances are NOT equal."
- }
-
- <
- .SYNOPSIS
- This script gets and displays the file version information of a file
- .DESCRIPTION
- This script calls System.Diagnostics.FileVersionInfo's
- GetVersion info method on the file. By default, the file version
- displayed/returned is that of %systemroot%\notepad.exe.
- .NOTES
- File Name : Get-FileVersionInfo.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- Note : The file named passed to GetVersionInfo needs to
- be fully qualified, not just local name.
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN Sample posted at:
- http://msdn.microsoft.com/en-us/library/system.diagnostics.fileversioninfo.aspx
- .EXAMPLE
- PSH [C:\foo]: .\Get-FileVersionInfo.ps1
- File Description : Notepad
- File Version : 6.0.6000.16386 (vista_rtm.061101-2205)
- .EXAMPLE
- PSH [C:\Foo]: .\Get-FileVersionInfo.ps1' c:\windows\fveupdate.exe
- File Description : BitLocker Drive Encryption Servicing Utility
- File Version : 6.0.6000.16386 (vista_rtm.061101-2205)
- .PARAMETER filename
- The name of the file for which file version information is displayed.
-
-
- param (
- [string] $filename = $(join-path ${env:systemroot} "Notepad.Exe")
- )
-
-
-
-
-
- $info= [system.Diagnostics.FileVersionInfo]::GetVersionInfo($filename)
- "File Description : {0}" -f $info.filedescription
- "File Version : {0}" -f $info.fileversion
-
- <
- .SYNOPSIS
- This script reads a simple XML file and prints the results
- .DESCRIPTION
- This script is a re-write of an XML C
- .NOTES
- File Name : get-xmlfilecontents.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- Books3.xml =
- <book>
- <title>C
- <price>20</price>
- </book>
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN Sample posted at:
- http://msdn.microsoft.com/en-us/library/t9bfea29.aspx
- .EXAMPLE
- PSH [C:\foo]: .\Get-XMLFileContents.PS1
- The content of the title element: C
- The content of the price element: 20
-
-
-
-
-
-
-
-
- $reader = [system.Xml.XmlReader]::Create("C:\foo\book3.xml")
-
-
-
- $result=$reader.Read()
-
-
- $reader.ReadStartElement("book")
- $reader.ReadStartElement("title")
- "The content of the title element: {0}" -f $reader.ReadString()
- $reader.ReadEndElement()
-
-
- $reader.ReadStartElement("price")
- "The content of the price element: {0}" -f $reader.ReadString()
- $reader.ReadEndElement()
- $reader.ReadEndElement()
-
- <
- .SYNOPSIS
- Demonstrates use of the System.Diagnostics.Stopwatch .NET Class
- .DESCRIPTION
- This script is a community content MSDN sample,using PowerShell
- .NOTES
- File Name : Get-ElapsedTime
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- Sample posted to:
- http://pshscripts.blogspot.com
- Original MSDN sample at:
- http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx
- .EXAMPLE
- PSH [C:\foo]: .\get-stopwatch.ps1'
- Runtime = 00:00:10.03
-
-
-
-
-
-
-
-
- $StopWatch = New-Object system.Diagnostics.Stopwatch
-
-
- $stopWatch.Start()
-
-
- [system.threading.Thread]::Sleep(10000)
-
-
- $StopWatch.Stop();
-
-
- $ts = $StopWatch.Elapsed
-
-
- $ElapsedTime = [system.String]::Format("{0:00}:{1:00}:{2:00}.{3:00}",
- $ts.Hours, $ts.Minutes, $ts.Seconds,
- $ts.Milliseconds / 10);
- "Runtime = $elapsedTime"
- <
- .SYNOPSIS
- This script displays the use of the Reset method in a StopWatch object.
- .DESCRIPTION
- This script calls the StartNew static method to create and start a new
- stopwatch object, and displays the current values for the stop watch. The
- stopwatch is then reset using the Reset method, then the current values are displayed. At completion,
- the stopwatch is stopped and all counters are zero.
- .NOTES
- File Name : Clear-Stopwatch.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN Sample posted at:
- http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.reset.aspx
- .EXAMPLE
- PSH [C:\foo]: .\Clear-Stopwatch.ps1
- StopWatch object before reset:
- IsRunning : True
- Elapsed : 00:00:00.0039085
- ElapsedMilliseconds : 3
- ElapsedTicks : 57153
- StopWatch object after reset:
- IsRunning : False
- Elapsed : 00:00:00
- ElapsedMilliseconds : 0
- ElapsedTicks : 0
-
-
-
-
-
-
- $sw = [system.Diagnostics.Stopwatch]::StartNew()
-
-
- "StopWatch object before reset:"
- $sw | fl *
-
-
- $sw.reset()
-
-
- "StopWatch object after reset:"
- $sw | fl *
-
- <
- .SYNOPSIS
- Gets LegalCopyright and Legal Trademarks from a file, if they exist.
- .DESCRIPTION
- This script uses System.Diagnostic.FileVersionInfo to get the version information
- of a file. in this sample, I use notepad.exe, as shipped with Windows.
-
- If you look at the output, you see LegalTrademarks are empty - this is the result I get on my
- main workstation.
- .NOTES
- File Name : Get-LegalInfo.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- PSH [C:\foo]: .\Get-LegalInfo.ps1
- LegalCopyright : c Microsoft Corporation. All rights reserved.
- Legal Trademarks:
-
-
-
-
-
-
- $MyFileVersionInfo = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\windows\Notepad.exe")
-
-
- "LegalCopyright : {0}" -f $MyFileVersionInfo.LegalCopyright
- "Legal Trademarks: {0}" -f $myFileVersionInfo.LegalTrademarks
-
- <
- .SYNOPSIS
- Gets and displays properties of a stopwatch
- .DESCRIPTION
- This script, written as an MSDN Sample, creates and starts a stop watch. The
- script stops the stopwatch, and displays the properties. To some degree, the
- results indicate how long it takes to start and stop a stopwatch. Also, the
- runtimes vary if you run it multiple times.
- .NOTES
- File Name : Get-StopWatchProperties.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- Original sample posted at: http://pshscripts.blogspot.com/2009/05/get-stopwatchpropertiesps1.html
- MSDN Sample posted at: http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch_properties.aspx
- .EXAMPLE
- PSH [C:\foo]: .\Get-StopWatchProperties.PS1'
- IsRunning : False
- Elapsed : 00:00:00.0000162
- ElapsedMilliseconds : 0
- ElapsedTicks : 233
-
-
-
-
-
-
-
-
-
- $StopWatch = New-Object System.Diagnostics.Stopwatch
-
-
- $StopWatch.start()
- $StopWatch.stop()
-
-
-
- $stopwatch | Format-List *
-
- <
- .SYNOPSIS
- This script uses WMI to print a test page
- all printers on this system
- .DESCRIPTION
- This script is an MSDN sample,using PowerShell. It first
- gets all the printrs installed, prints out details then
- tries to print a test page.
-
- The script also checks for printers known to not work well, and avoids using them
- .NOTES
- File Name : Get-PrinterTestPage.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- Sample posted to:
- http://pshscripts.blogspot.com/2009/04/get-printertestpageps1.html
- Original MSDN sample at:
- http://msdn.microsoft.com/en-us/library/aa392757(VS.85).aspx
- .EXAMPLE
- PSH [C:\foo]: .Get-PrinterTestPage.ps1'
- 4 Printers defined on this system
- Printer share name: \
- Printer Port : C:\ProgramData\TechSmith\SnagIt 9\PrinterPortFile
- Printer share name: \Phaser PS
- Printer Port : X_10.10.1.117
- Printer share name: \
- Printer Port : XPSPort:
- Printer share name: \\SLT-PC\officejet
- Printer Port : USB002
-
- Printing test page for printer: SnagIt 9
- Not printing a test page for this printer
- Printing test page for printer: Phaser PS
- Result : 0
- Printing test page for printer: Microsoft XPS Document Writer
- Not printing a test page for this printer
- Printing test page for printer: \\JerryGarcia\HP Officejet Pro L7400 Series
- Result : 0
-
-
-
-
-
-
-
- $printers = Get-WmiObject -Class Win32_Printer
-
- "{0} Printers defined on this system" -f $printers.count
-
-
- foreach ($printer in $printers) {
- "Printer share name: {0}\{1}" -f $printer.servername, $printer.sharename
- "Printer Port : {0} " -f $printer.PortName
- }
- ""
-
-
- foreach ($printer in $printers) {
- "Printing test page for printer: {0}" -f $printer.name
-
- if ($printer.DriverName -match "XPS" -or $printer.DriverName -match "SnagIt") {
- "Not printing a test page for this printer"
- }
- else {
- $Result = $printer.PrintTestPage()
- "Result : {0}" -f $Result.ReturnValue
- }
- }
-
- <
- .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"
- )
-
-
-
-
-
-
-
- $hostentrydetails = [System.Net.Dns]::GetHostEntry($hostname)
-
-
- "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
- }
-
-