Thursday, 9 July 2009

Copy-File.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script displays the usage of the Exists and the 
  4.     copy methods of System.IP.File   
  5. .DESCRIPTION 
  6.     This script sets up two file names, then checks to see if 
  7.     the sorucefile exists. if so, it's copied to a new file. 
  8. .NOTES 
  9.     File Name  : copy-file.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell V2 CTP3 
  12. .LINK 
  13.     This script posted to: 
  14.         http://www.pshscripts.blogspot.com 
  15.     MSDN Sample posted at: 
  16.         http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx 
  17. .EXAMPLE 
  18.     PSH [C:\foo]: .\Copy-File.PS1' 
  19.     Source File (c:\foo\Test.txt) copied to (c:\foo\Test2.txt) 
  20. #> 
  21.  
  22. ## 
  23. # start of script 
  24. ## 
  25.  
  26. # Setup source and destination files 
  27. $SourceFile = "c:\foo\Test.txt"
  28. $NewFile    = "c:\foo\Test2.txt"
  29.  
  30. # Now - check to see if $Sourcefile exists, and if so, 
  31. # copy it to $newfile  
  32. if ([System.IO.File]::Exists($SourceFile))  { 
  33.    [System.IO.File]::Copy($SourceFile, $NewFile
  34.    "Source File ($SourceFile) copied to ($newFile)" 
  35. else
  36. "Source file ($Sourcefile) does not exist." 
  37. # End of script 

Monday, 6 July 2009

Happy 1st Birthday To HTTP://PshScripts.Blogspot.Com!!!

I’ve been posting scripts here for just over a year – the first script was posted on July 5th 2008. There have been 127 posts, and the downloadable script library now has 141 scripts.

Here are some monthly stats for the past year:

 

image

The readership of the blog was not great till I started posting in ernest in November. Since then, there’s been a slow rise each month as more folks find the blog. When I first started this blog, the idea was to post just scripts – on the assumption that folks would find them using Google, et al. And that’s pretty much what has happened. Looking at the last 20 blog hits as an example: 3 of the 20 were direct access, with 17 coming from a referral. Of the 17 referrals, 12 came from Google (google.com, google.it, google.co.uk, google.bg, google.pl), 2 from Bing and one each from Hal Rotenbergs blog, Technet and PowerShell.com. It’s also clear that the readership is pretty international:

image

Technorati Tags:

I hope this blog and the scripts posted here have been of use. Please feel free to comment on other scripts you’d like to see here!

Compare-Int32.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script illustrates the CompareExchange Method 
  4. .DESCRIPTION 
  5.     This script creates three values, and calls CompareExchange method, 
  6.     and displays the results. The first time, we compare two non-equal values 
  7.     so no exchange is done. The second time, the comparison succeeds and the 
  8.     value us updated.    
  9. .NOTES 
  10.     File Name  : Compare-Int32.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/801kt583.aspx 
  18. .EXAMPLE 
  19.     PSH [C:\foo]: .\Compare-int32.PS1 
  20.     Before 1st call: 
  21.     42 
  22.     69 
  23.     104 
  24.   
  25.     After 1st call, before 2nd 
  26.     42 
  27.     69 
  28.     104 
  29.   
  30.     After 2nd call 
  31.     69 
  32.     69 
  33.     104 
  34. #> 
  35.  
  36. ## 
  37. # Start of Script 
  38. ## 
  39.  
  40. # Create 3 int32 values 
  41.  
  42. [int32] $a=42 
  43. [int32] $b=69 
  44. [int32] $c=104 
  45.  
  46. # Display values before 
  47. "Before 1st call:";$a,$b,$c 
  48. "" 
  49.  
  50. # Call CompareExchange and print results 
  51. # This call compares $a with $c, so there are not equal 
  52. $result = [System.Threading.Interlocked]::CompareExchange([ref]$a, $b, $c
  53. "After 1st call, before 2nd" 
  54. $a,$b,$c 
  55. "" 
  56.  
  57. # Call CompareExchange and print results 
  58. # This call compares $a with $A, so this call 
  59. # returns $a updated to $b 
  60. $result = [System.Threading.Interlocked]::CompareExchange([ref]$a, $b, $a
  61. "After 2nd call" 
  62. $a,$b,$c 

Wednesday, 1 July 2009

Compare-Double

  1. <# 
  2. .SYNOPSIS 
  3.     This script illustrates the CompareExchange Method 
  4. .DESCRIPTION 
  5.     This script creates three values, and calls CompareExchange method, 
  6.     and displays the results. The first time, we compare to non-equal values 
  7.     so no exchange is done. The second time, the comparison succeeds and the 
  8.     value us updated.    
  9. .NOTES 
  10.     File Name  : Compare-Double.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/cd0811yf.aspx 
  18. .EXAMPLE 
  19.     PSH [C:\foo]: .\Compare-Double.PS1
  20.     Before 1st call: 
  21.     42.42 
  22.     69.69 
  23.     104.4 
  24.   
  25.     After 1st call, before 2nd 
  26.     42.42 
  27.     69.69 
  28.     104.4 
  29.   
  30.     After 2nd call 
  31.     69.69 
  32.     69.69 
  33.     104.4 
  34. #> 
  35.  
  36. ## 
  37. # Start of Script 
  38. ## 
  39.  
  40. # Create 3 double values 
  41.  
  42. [double] $a=42.42 
  43. [double] $b=69.69 
  44. [double] $c=104.4 
  45.  
  46. # Display values before 
  47. "Before 1st call:";$a,$b,$c 
  48. "" 
  49.  
  50. # Call CompareExchange and print results 
  51. # This call compares $a with $c, so there are not equal 
  52. $result = [system.Threading.Interlocked]::CompareExchange([ref]$a, $b, $c
  53. "After 1st call, before 2nd" 
  54. $a,$b,$c 
  55. "" 
  56. # Call CompareExchange and print results 
  57. # This call compares $a with $A, so this call 
  58. # returns $a updated to $b 
  59. $result = [system.Threading.Interlocked]::CompareExchange([ref]$a, $b, $a
  60. "After 2nd call" 
  61. $a,$b,$c 

Sunday, 28 June 2009

Get-TypeTest.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script displays the value, and type, of an expression. 
  4. .DESCRIPTION 
  5.     This script is a rewrite of the second example on this page, The  
  6.     script illustrates how to use the GetType method to return 
  7.     the type that results from a calculation. in this case, two  
  8.     multiplying two int32 with the Pi field results in a System.Double. 
  9. .NOTES 
  10.     File Name  : Get-TypeTest.ps1 
  11.     Author     : Thomas Lee - tfl@psp.co.uk 
  12.     Requires   : PowerShell V2 CTP3 
  13. .LINK 
  14.     This script posted to: 
  15.         http://pshscripts.blogspot.com/2009/06/get-typetestps1.html
  16.     MSDN Sample posted at: 
  17.         http://msdn.microsoft.com/en-us/library/58918ffs.aspx 
  18. .EXAMPLE 
  19.     PSH [C:\foo]: .\Get-TypeTest.PS1 
  20.     The type of $Radius is       : System.Int32 
  21.     Area =                         28.2743338823081 
  22.     The type is the expression is: System.Double 
  23. #> 
  24.  
  25. ## 
  26. # Start of Script 
  27. ## 
  28.   
  29. # Set and display type of radius 
  30. [int] $radius = 3 
  31. "The type of `$Radius is       : {0}" -f $radius.GetType() 
  32.  
  33. # Display Area, and the type of an expression. 
  34. "Area                           {0}" -f ($radius * $radius * [System.Math]::PI) 
  35. "The type is the expression is: {0}" -f ($radius * $radius * [System.Math]::PI).GetType() 
  36. # End of Script 

Wednesday, 17 June 2009

Get-ConformanceLevelEnum.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script demonstrates the confirmance level enum. 
  4. .DESCRIPTION 
  5.     This script displays the values form the conformancelevel enum 
  6.     and checks it against a value. 
  7. .NOTES 
  8.     File Name  : Get-ConformanceLevelEnum.ps1 
  9.     Author     : Thomas Lee - tfl@psp.co.uk 
  10.     Requires   : PowerShell V2 CTP3 
  11. .LINK 
  12.     This script posted to: 
  13.         http://pshscripts.blogspot.com 
  14.     MSDN Sample posted at: 
  15.         http://msdn.microsoft.com/en-us/library/h2344bs2(VS.85).aspx 
  16. .EXAMPLE 
  17.     PSH [C:\foo]: .\Get-ConformanceLevelEnum.ps1' 
  18.     System.XML.ConformanceLevel enum has 3 possible values 
  19.     Value 1: Auto 
  20.     Value 2: Fragment 
  21.     Value 3: Document 
  22.      
  23.     $ToCheck1 is NOT document 
  24.     $ToCheck2 is Document 
  25. #> 
  26.  
  27. ## 
  28. # Start of script 
  29. ## 
  30. # Demonstrates the ConformanceLevel enum 
  31. # Thomas Lee - tfl@psp.co.uk 
  32. # Enumerate the enum 
  33. $enums=[enum]::GetValues([System.Xml.ConformanceLevel]) 
  34.  
  35. # Display 
  36. "System.XML.ConformanceLevel enum has {0} possible values" -f $enums.count 
  37. $i=1 
  38. $enums| %{"Value {0}: {1}" -f $i,$_.tostring();$i++} 
  39. "" 
  40. # Checking against a an enum value  
  41. $ToCheck1 = "somethingelse" 
  42. $Tocheck2 = "document" 
  43. if ($ToCheck1 -eq  [System.XML.ConformanceLevel]::Document) { 
  44.   "`$ToCheck1 is document"
  45. else
  46.   "`$ToCheck1 is NOT document" 
  47.    
  48. if ($ToCheck2 -eq  [System.XML.ConformanceLevel]::Document) { 
  49.  "`$ToCheck2 is Document"
  50. else
  51.  "`$ToCheck2 is NOT document" 
  52. }  
  53. #End of Script 

Monday, 15 June 2009

Get-TimeTick.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script gets and displays the static Tick values from TimeSpan Object 
  4. .DESCRIPTION 
  5.     This script 
  6. .NOTES 
  7.     File Name  : Get-TimeTick.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.timespan.tickspersecond(VS.85).aspx 
  15. .EXAMPLE 
  16.     PSH [C:\foo]: .\Get-TimeTick.ps1 
  17.     Ticks Per: 
  18.     Day         : 864,000,000,000 
  19.     Hour        :  36,000,000,000 
  20.     Minute      :     600,000,000 
  21.     Second      :      10,000,000 
  22.     Millisecond :          10,000 
  23. #> 
  24.  
  25. ## 
  26. # Start of script 
  27. ## 
  28.   
  29. # Create the values 
  30. $tsticksperday         = [system.timespan]::ticksperday 
  31. $tsticksperhour        = [system.timespan]::ticksperhour 
  32. $tstickspermillisecond = [system.timespan]::TicksPerMillisecond 
  33. $tsticksperminute      = [system.timespan]::ticksperminute 
  34. $tstickspersecond =      [system.timespan]::tickspersecond 
  35.  
  36. # Display results nicely formatted 
  37. "Ticks Per:"  
  38. "Day         : {0, 15}" -f $tsticksperday.tostring("###,###"
  39. "Hour        : {0, 15}" -f $tsticksperhour.tostring("###,###"
  40. "Minute      : {0, 15}" -f $tsticksperminute.tostring("###,###"
  41. "Second      : {0, 15}" -f $tstickspersecond.tostring("###,###"
  42. "Millisecond : {0, 15}" -f $tstickspermillisecond.tostring("###,###"
  43. #End of Script 

Sunday, 14 June 2009

Get-JapaneseDate.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script displays dates using the Japanese calander. 
  4. .DESCRIPTION 
  5.     This script creates a new date and time object, then displays  
  6.     things using the Japanese calendar. I have changed the original 
  7.     script slightly to show the different eras in use.  
  8. .NOTES 
  9.     File Name  : Get-JapaneseDate.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell V2 CTP3 
  12. .LINK 
  13.     This script posted to: 
  14.         http://pshscripts.blogspot.com/2009/06/get-japanesedateps1.html
  15.     MSDN Sample posted at: 
  16.         http://msdn.microsoft.com/en-us/library/system.globalization.japanesecalendar.getyear.aspx 
  17. .EXAMPLE 
  18.     PSH [C:\foo]: .\Get-Japanesedate.ps1' 
  19.     April 3, 1875 of the Gregorian calendar equals the following in the Japanese calendar: 
  20.        Era:        1 
  21.        Year:       8 
  22.        Month:      4 
  23.        DayOfYear:  93 
  24.        DayOfMonth: 3 
  25.        DayOfWeek:  Saturday 
  26.   
  27.     After adding 138 years and 10 months: 
  28.        Era:        4 
  29.        Year:       26 
  30.        Month:      2 
  31.        DayOfYear:  34 
  32.        DayOfMonth: 3 
  33.        DayOfWeek:  Monday 
  34. #> 
  35. ## 
  36. # start of script 
  37. ## 
  38.  
  39. # Helper function 
  40. function DisplayJapaneseDateValue{ 
  41. Param ( $DT ) # 
  42. # create a Japenese calendar 
  43. $cal=new-object System.Globalization.JapaneseCalendar 
  44.   
  45.  # display dates using that calendar 
  46. "   Era:        {0}" -f $Cal.GetEra($DT)  
  47. "   Year:       {0}" -f $Cal.GetYear($DT)  
  48. "   Month:      {0}" -f $Cal.GetMonth($DT
  49. "   DayOfYear:  {0}" -f $Cal.GetDayOfYear($DT
  50. "   DayOfMonth: {0}" -f $Cal.GetDayOfMonth($DT
  51. "   DayOfWeek:  {0}" -f $Cal.GetDayOfWeek($DT)  
  52. "" 
  53.   
  54. # Set a DateTime to April 3, 1875 of the Gregorian calendar.  
  55. # This date is in the Meiji era (era 1) 
  56. $myDT = new-object System.DateTime 1875, 4, 3,(New-Object System.Globalization.GregorianCalendar) 
  57.   
  58. # Display the values of the DateTime 
  59. "April 3, 1875 of the Gregorian calendar equals the following in the Japanese calendar:"  
  60. DisplayJapaneseDateValue $myDT  
  61.   
  62. # Add 138 years and 10 months 
  63. # This takes the date into the Heisei era (era 4) 
  64. $myDT = $myCal.AddYears( $myDT, 138 ) 
  65. $myDT = $myCal.AddMonths($myDT, 10 ) 
  66.   
  67. # Displays the values of the DateTime. 
  68.  "After adding 138 years and 10 months:"  
  69. DisplayJapaneseDateValue $myDT  
  70. # end of script 

Sunday, 7 June 2009

Get-Cookie.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script gets and displays the cookies returned from a site. 
  4. .DESCRIPTION 
  5.     This script calls System.Net.WebRequest to get a page. in the  
  6.     response there may be cookies returned which this script then 
  7.     displays. By default, the cookies returned from the MSDN home page 
  8.     are displayed. To improve production orientation, the creation of 
  9.     the request and getting the response are protected by try/catch 
  10.     blocks. 
  11. .NOTES 
  12.     File Name  : get-cookie.ps1 
  13.     Author     : Thomas Lee - tfl@psp.co.uk 
  14.     Requires   : PowerShell V2 CTP3 
  15.      
  16. .LINK 
  17.     This script posted to: 
  18.         http://www.pshscripts.blogspot.com 
  19.     MSDN Sample posted at: 
  20.         http://msdn.microsoft.com/en-us/library/system.net.cookie.aspx 
  21. .EXAMPLE 
  22.     PSH [C:\foo]: .\Get-Cookie.ps1 
  23.     3 Cookies returned from: http://www.microsoft.com/msdn 
  24.      
  25.     Cookie: 
  26.     A = I&I=AxUFAAAAAADmCwAA/fh06TVFlKw6GSuBKKj6Yg!!&M=1 
  27.     Domain      : .microsoft.com 
  28.     Path        : / 
  29.     Port        : 
  30.     Secure      : False 
  31.     When issued : 6/7/2009 10:06:30 AM 
  32.     Expires     : 
  33.     Expired?    : False 
  34.     Don’t save  : False
  35.     Comment     :
  36.     URI for Comments:
  37.     Version     : 0
  38.     String      : A=I&I=AxUFAAAAADmCwAA/fh06TVFlKw6GSuBKKj6Yg!!&M=1 :
  39.     Cookie:
  40.     ADS = SN=175A21EF
  41.     Domain      : .microsoft.com
  42.     Path        : /
  43.     Port        :
  44.     Secure      :
  45.     When issued : 6/7/2009 10:06:30 AM
  46.     Expires     :
  47.     Expired?    : false
  48.     Don’t save  : false  
  49.     Comment     : 
  50.     Uri for comments: 
  51.     Version     : 0 
  52.     String: ADS=SN=175A21EF : 
  53.      
  54.     Cookie: 
  55.     mediaRssUrl = http://www.microsoft.com/feeds/msdn/en-us/HDI/Home-HDI.xml 
  56.     Domain      : msdn.microsoft.com 
  57.     Path        : / 
  58.     Port        : 
  59.     Secure      : False 
  60.     When issued : 6/7/2009 10:06:30 AM 
  61.     Expires     : 
  62.     Expired?    : False 
  63.     Don’t save  : False
  64.     Comment     :
  65.     Uri for comments :
  66.     Version     : 0
  67.     String      : mediaRssUrl=http://www.microsoft.com/feeds/msdn/en-us/HDI/Home-HDI.xml :
  68. #>
  69. param {
  70. $site = “http://www.microsoft.com/msdn”
  71. ) 
  72.    
  73. ## 
  74. # Start of script 
  75. ## 
  76.   
  77. # Create the web request object, catching any errors 
  78. try { 
  79. $request = [System.Net.WebRequest]::Create($site) 
  80. $request.CookieContainer = New-Object System.Net.CookieContainer 
  81. } 
  82. catch { 
  83. "Error creating request";$requst 
  84. return 
  85. } 
  86.   
  87. # Now get response 
  88. try { 
  89. $response = $request.GetResponse() 
  90. } 
  91. catch { 
  92. "Error getting response from $site - try later" 
  93. return 
  94. } 
  95.   
  96. # Print number of cookies 
  97. if ($response.Cookies.Count -gt 0) { 
  98. "{0} Cookies returned from: {1}" -f $Response.Cookies.Count,$site 
  99. "" 
  100. } 
  101.   
  102. # Print the properties of each cookie. 
  103. foreach ($cook in $Response.Cookies)    { 
  104. "Cookie:" 
  105. "{0} = {1}"    -f $cook.Name, $cook.Value 
  106. "Domain      : {0}"     -f $cook.Domain 
  107. "Path        : {0}"     -f $cook.Path 
  108. "Port        : {0}"     -f $cook.Port 
  109. "Secure      : {0}"     -f $cook.Secure 
  110. "When issued : {0}"     -f $cook.TimeStamp 
  111. "Expires     : {0}"     -f $cook.expireds 
  112. "Expired?    : {0}"     -f $cook.expired 
  113. "Don't save  : {0}"     -f $cook.Discard 
  114. "Comment     : {0}"     -f $cook.Comment 
  115. "Uri for comments: {0}" -f $cook.CommentUri 
  116. "Version     : {0}"     -f $cook.Version 
  117. "String: {0} :"         -f $cook.ToString() 
  118. "" 
  119. # End of Script 

Saturday, 6 June 2009

Get-ProcessPerfCounter.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script creates a process, then displays some performance counters. 
  4. .DESCRIPTION 
  5.     This script calls System.Diagnostics.Process's Start static 
  6.     method to create a process.  Then it displays perf stats till the
  7.     process is stopped. Then it prints final stats out.
  8. .NOTES 
  9.     File Name  : Get-ProcessPerfCounter 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell V2 CTP3 
  12. <# 
  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.process.peakworkingset64.aspx 
  18. .EXAMPLE 
  19.     PSH [C:\foo]: .\Get-ProcessPerfCounter.ps1 
  20.  
  21.     System.Diagnostics.Process (notepad) - 
  22.     ------------------------------------- 
  23.       physical memory usage     : 2,512 
  24.       base priority             : 8 
  25.       priority class            : Normal 
  26.       user processor time       : 00:00:00.0156001 
  27.       privileged processor time : 00:00:00.0156001 
  28.       total processor time      : 00:00:00.0312002 
  29.   
  30.     ** Loads more - snipped for brevity ** 
  31.      
  32.     System.Diagnostics.Process (notepad) - 
  33.     ------------------------------------- 
  34.       physical memory usage     : 12,424 
  35.       base priority             : 8 
  36.       priority class            : Normal 
  37.       user processor time       : 00:00:00.0156001 
  38.       privileged processor time : 00:00:00.0624004 
  39.       total processor time      : 00:00:00.0780005 
  40.   
  41.       Process has ended 
  42.       Process exit code: 0 
  43.       Peak physical memory usage of the process :  12,424 kb 
  44.       Peak paged memory usage of the process    :   2,740 kb 
  45.       Peak virtual memory usage of the process  :  88,832 kb 
  46. #> 
  47.   
  48. ## 
  49. # Start of script 
  50. ## 
  51.    
  52. # Start up Notepad, catching issues 
  53. try  { 
  54. $myproc =  [System.Diagnostics.Process]::Start("c:\windows\notepad.exe"
  55. catch { 
  56.   "Error starting process" 
  57.   return 
  58.   
  59. # Now print perf stats until Notepad.exe is closed 
  60. do { 
  61.   if ( ! $myproc.HasExited ) { 
  62.   $myproc.Refresh() 
  63.   "" 
  64.   "{0} -"        -f $myProc.ToString() 
  65.   "-------------------------------------" 
  66.   "  physical memory usage     : {0}" -f $($MyProc.WorkingSet64/1kb).tostring("###,###"
  67.   "  base priority             : {0}" -f $MyProc.BasePriority 
  68.   "  priority class            : {0}" -f $MyProc.PriorityClass 
  69.   "  user processor time       : {0}" -f $MyProc.UserProcessorTime 
  70.   "  privileged processor time : {0}" -f $MyProc.PrivilegedProcessorTime 
  71.   "  total processor time      : {0}" -f $MyProc.TotalProcessorTime 
  72.     
  73. # calculate overall peak 
  74. $peakPagedMem   = $MyProc.PeakPagedMemorySize64 
  75. $peakVirtualMem = $MyProc.PeakVirtualMemorySize64 
  76. $peakWorkingSet = $MyProc.PeakWorkingSet64 
  77.   
  78. } # end of if 
  79.      
  80. } # end of do 
  81. while (!$myproc.WaitForExit(1000)) # Wait a second and do it again 
  82.  
  83. # Here process has exited 
  84. # Print out final results 
  85. "" 
  86. "Process has ended" 
  87. "Process exit code: {0}" -f $MyProc.ExitCode 
  88.  
  89. # Display peak memory statistics for the process. 
  90. "Peak physical memory usage of the process : {0,7} kb" -f $($peakWorkingSet/1kb).ToString("###,###"
  91. "Peak paged memory usage of the process    : {0,7} kb" -f $($peakPagedMem/1kb).ToString("###,###"
  92. "Peak virtual memory usage of the process  : {0,7} kb" -f $($peakVirtualMem/1kb).ToString("###,###"
  93. # End of script