- <
- .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 *
-