Monday, 16 August 2010

Get-Sha1HashFile.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script uses the SHA1 Crypto Provider to hash a file 
  4. .DESCRIPTION 
  5.     This script uses SHA1 Cryptoprovider to hash a file and print the hash. A second 
  6.     hash is created of the same file, but with a space added. The file I picked is a 
  7.     large text file I keep in c:\foo for uses like this! 
  8. .NOTES 
  9.     File Name  : Get-Sha1HashFile.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell Version 2.0 
  12. .LINK 
  13.     This script posted to: 
  14.         http://www.pshscripts.blogspot.com 
  15.     Posted to TechEd Sample Gallery at: 
  16.  
  17. .EXAMPLE 
  18.     PSH [C:\foo]: .\Get-Sha1HashFile.ps1 
  19.     Hashing     : C:\foo\gd.txt 
  20.     Results in  : 760bb67356560232 
  21.     Hashing     :  C:\foo\gd.txt + space 
  22.     Results in  : 4f7b4902168bba7d 
  23.      
  24. #> 
  25.  
  26. # Create Input Data 
  27. $file       = (ls c:\foo\*.txt | sort -descending length)[0] # get largest file 
  28. $filestr    = Get-Content $file 
  29. $filebytes1 = [System.Text.UnicodeEncoding]::Unicode.getbytes($files
  30. $filebytes2 = [System.Text.UnicodeEncoding]::Unicode.getbytes($files+" "
  31.  
  32. # Create a New SHA1 Crypto Provider 
  33. $sha = New-Object System.Security.Cryptography.SHA1CryptoServiceProvider 
  34.  
  35. # Now hash that 
  36. $result1 = $sha.ComputeHash($filebytes1
  37. "Hashing     : {0}" -f $file.FullName 
  38. "Results in  : {0}" -f [system.BitConverter]::ToUint64($result1,0).tostring("x"
  39.  
  40. $result2 = $sha.ComputeHash($filebytes2
  41. "Hashing     : {0}" -f " $($file.FullName) + space" 
  42. "Results in  : {0}" -f [system.BitConverter]::ToUint64($result2,0).tostring("x"

Friday, 13 August 2010

Get-Sha1Hash.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script uses the SHA1 Crypto Provider to hash a string 
  4. .DESCRIPTION 
  5.     This script creates 2 strings, and a SHA1 Crypto Provider. 
  6.     The script then hashes the strings and displays the results.  
  7. .NOTES 
  8.     File Name  : Get-Sha1Hash.ps1 
  9.     Author     : Thomas Lee - tfl@psp.co.uk 
  10.     Requires   : PowerShell Version 2.0 
  11. .LINK 
  12.     This script posted to: 
  13.         http://www.pshscripts.blogspot.com 
  14.     MSDN Sample posted at: 
  15.         http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha1cryptoserviceprovider.aspx 
  16.     Posted to TechEd Sample Gallery at: 
  17.      
  18. .EXAMPLE 
  19.     PSH [C:\foo]: . 'E:\PowerShellScriptLib\System.Security.Crpytography\Get-Sha1Hash.ps1' 
  20.     Hashing     : This is a string to hash 
  21.     Results in  : z→???_r♠W??o???]rv?? 
  22.   
  23.     Hashing     : this is a string to hash 
  24.     Results in  : ???☺$?Z??♀???????U?' 
  25. #> 
  26.  
  27. # Create Input Data 
  28. $enc = [system.Text.Encoding]::ASCII 
  29. $string1 = "This is a string to hash" 
  30. $string2 = "this is a string to hash" 
  31. $data1 = $enc.GetBytes($string1
  32. $data2 = $enc.GetBytes($string2
  33.  
  34. # Create a New SHA1 Crypto Provider 
  35. $sha = New-Object System.Security.Cryptography.SHA1CryptoServiceProvider 
  36.  
  37. # Now hash and display results 
  38. $result1 = $sha.ComputeHash($data1
  39. "Hashing     : {0}" -f $string1 
  40. "Results in  : {0}" -f $enc.Getstring($result1
  41. "" 
  42.  
  43. $result2 = $sha.ComputeHash($data2
  44. "Hashing     : {0}" -f $string2 
  45. "Results in  : {0}" -f $enc.Getstring($result2

Thursday, 12 August 2010

Get-DnsRegisteredServers.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script gets the reverse lookup zone from a DNS Server and 
  4.     displays all the systems registered 
  5. .DESCRIPTION 
  6.     This script first gets the reverse lookup zone from a DNS Server (i.e. 
  7.     all the computers that have used the DNS server to register!). The 
  8.     script then displays the FQDN, IP Address and Timestamp. 
  9. .NOTES 
  10.     File Name  : Get-DnsRegisteredServers.ps1 
  11.     Author     : Thomas Lee - tfl@psp.co.uk 
  12.     Requires   : PowerShell Version 2.0 
  13. .LINK 
  14.     This script posted to: 
  15.         http://www.pshscripts.blogspot.com 
  16.     This script posted to TechNet Scripting Gallery 
  17.         http://gallery.technet.microsoft.com/ScriptCenter/en-us/28e8b98e-565b-40be-ba2c-1134341bb555     
  18. .EXAMPLE 
  19.     PSH [C:\foo]: .Get-DnsRegisteredNames.ps1 
  20.     Computers reverse registered on DNS Server: Cookham1 
  21.     10.10.1.42      superman.cookham.net.                     3590550 
  22.     10.10.1.105     batman.cookham.net.                       3582112 
  23.     10.10.1.109     jeeves.cookham.net.                       3586452 
  24.     10.10.1.111     supergirl.cookham.net.                    3590550 
  25.     10.10.1.114     future.cookham.net.                       3589209 
  26.     10.10.1.131     bladerunner.cookham.net.                  3587817 
  27.     10.10.1.142     wonderwoman.kapoho.net.                   3590551 
  28. #> 
  29.  
  30. $dns = "Cookham1"  
  31. $records = get-wmiobject -class MicrosoftDNS_PTRType -namespace root\MicrosoftDNS -computer $dns  
  32.  
  33. "Computers reverse registered on DNS Server: $DNS" 
  34.  
  35. # Loop through and display results 
  36. foreach ($record in $records) { 
  37.  
  38. # Get owner name and ip address string 
  39. $on = $record.ownerName.split("."
  40. $ownerip = $on[3] + "." + $on[2] + "." + $on[1] + "." + $on[0] 
  41.  
  42. # Display details 
  43. "{0, -15} {1,-40}  {2,-10} " -f $ownerip, $record.ptrdomainname, $record.timestamp 

Wednesday, 11 August 2010

Get-EncryptedAesString.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script encrypts then decrypts a string using AES 
  4. .DESCRIPTION 
  5.     This script re-implements an MSDN sample that first  
  6.     encrypts a string then decrypts it. The crypto is done 
  7.     using AES. Running this script multiple times will result 
  8.     in differently encrypted quotes since a new key/IV is  
  9.     generated each time you run the script. 
  10. .NOTES 
  11.     File Name  : Get-AesEnctyptedString.ps1 
  12.     Author     : Thomas Lee - tfl@psp.co.uk 
  13.     Requires   : PowerShell Version 2.0 
  14. .LINK 
  15.     This script posted to: 
  16.         http://pshscripts.blogspot.com/2010/08/get-encryptedaesstringps1.html 
  17.     MSDN Sample posted at: 
  18.         http://msdn.microsoft.com/en-us/library/09d0kyb3.aspx  
  19. .EXAMPLE 
  20.     PSH [C:\foo]: .\Get-AesEncryptedString.ps1 
  21.     Quote: 
  22.     Things may come to those who wait, but only the things left by those who hustle. -- Abraham Lincoln 
  23.   
  24.     Encrypted Quote: 
  25.     zp4gD/Mmu01Msr3V8d94Kvwut4ClaW+f1HyohT+QjpFN5FVNhyLcQIgia4iD2TcsK/SpLcm5cOi1/KM+d9ENeU2Lkn8fOZHpMnklUrABGDoM1BRQDfWNcVbMIOA4IUY 
  26.     zLoJ5huHKhnyPA2fobGouW33HOpONI0zR3KS4RdtD3M3QQsqHW2+QOkE4/Ls/5gCSbcTuP2FDkk3J9b+1XgqzJZx0jZIBl+moUcqA33xQdu5bGhwg1E8sk2oEU8AQyy 
  27.     XcRrS/h8vTLve8c0Tpj4f2Vg== 
  28.   
  29.     Decrypted Quote: 
  30.     Things may come to those who wait, but only the things left by those who hustle. -- Abraham Lincoln 
  31. #> 
  32.  
  33.  
  34. # Best Practice! 
  35. Set-StrictMode  -version 2 
  36.   
  37. # Two helper functions 
  38. function EncryptString{ 
  39. param( $SymAlg,  
  40.       [string] $inString 
  41. $inBlock = [System.Text.UnicodeEncoding]::Unicode.getbytes($instring
  42. $xfrm = $symAlg.CreateEncryptor() 
  43. $outBlock = $xfrm.TransformFinalBlock($inBlock, 0, $inBlock.Length); 
  44. return $outBlock
  45.   
  46. function DecryptBytes { 
  47. param ($SymAlg,  
  48. $inBytes 
  49. $xfrm = $symAlg.CreateDecryptor(); 
  50. $outBlock = $xfrm.TransformFinalBlock($inBytes, 0, $inBytes.Length) 
  51. return [System.Text.UnicodeEncoding]::Unicode.GetString($outBlock
  52.  
  53. # main script 
  54. $Quote = "Things may come to those who wait, but only the "
  55.          "things left by those who hustle. -- Abraham Lincoln" 
  56. "Quote:";$Quote;"" 
  57.   
  58. # Generate CSP, Key and IV 
  59. $AesCSP = New-Object System.Security.Cryptography.AesCryptoServiceProvider 
  60. $AesCSP.GenerateKey() 
  61. $AesCSP.GenerateIV() 
  62.  
  63. # Encrypt quote 
  64. $EncQuote = EncryptString $aesCSP $quote 
  65. "Encrypted Quote:" 
  66. [System.Convert]::ToBase64String($encQuote
  67. "" 
  68.   
  69. # Now Decrypt  
  70. "Decrypted Quote:" 
  71. DecryptBytes $AesCSP $EncQuote 

Tuesday, 10 August 2010

Convert-Date.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script manipulates a time using TimeZone info methods. 
  4. .DESCRIPTION 
  5.     This script re-implements an MSDN sample using PowerShell. The script first 
  6.     creates a DateTime object then it converts it to Universal, UTC, Pacific and 'local' time.   
  7. .NOTES 
  8.     File Name  : Convert-Date.ps1 
  9.     Author     : Thomas Lee - tfl@psp.co.uk 
  10.     Requires   : PowerShell Version 2.0 
  11. .LINK 
  12.     This script posted to: 
  13.         http://pshscripts.blogspot.com/2010/08/convert-dateps1.html 
  14.     MSDN Sample posted at: 
  15.         http://msdn.microsoft.com/en-us/library/system.timezoneinfo.local.aspx  
  16. .EXAMPLE 
  17.     PSH [C:\foo]: . 'E:\PowerShellScriptLib\System.TimeZoneINfo\Convert-date.ps 
  18.     Date           : 3/21/2006 02:00:00 AM 
  19.     Local Time zone: GMT Standard Time 
  20.      In Universal time: 3/21/2006 02:00:00 AM 
  21.      In UTC           : 3/21/2006 02:00:00 AM 
  22.      In Local TZ:     : 3/21/2006 02:00:00 AM 
  23.      In Pacific TZ    : 3/21/2006 10:00:00 AM 
  24. #> 
  25. # Create date object 
  26. $date1 = New-Object System.DateTime 2006, 3, 21, 2, 0, 0 
  27.  
  28. # Display date and local time zone then show that time in other time zones 
  29. "Date           : {0}" -f $date1 
  30. "Local Time zone: {0}" -f  ([System.TimeZoneInfo]::Local).id 
  31. " In Universal time: {0}" -f $date1.ToUniversalTime() 
  32. " In UTC           : {0}" -f [System.TimeZoneInfo]::ConvertTimeToUtc($date1
  33. " In Local TZ:     : {0}" -f [System.TimeZoneInfo]::ConvertTimeToUtc($date1, ([System.TimeZoneInfo]::Local)) 
  34. $tz = [System.TimeZoneInfo]::FindSystemTimeZoneById("Pacific Standard Time");   
  35. " In Pacific TZ    : {0}" -f [System.TimeZoneInfo]::ConvertTimeToUtc($date1, $tz

Monday, 9 August 2010

Divide-BigInteger.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script divides big integers using .NET Framework. 
  4. .DESCRIPTION 
  5.     This script reimplements an MSDN Sample script using powershell. The 
  6.     script creates a dividor and an arry of dividends, then performs  
  7.     division operations several ways. 
  8. .NOTES 
  9.     File Name  : Divide-BigInteger.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell Version 2.0 
  12.                  .NET Framework 4.0 or higher 
  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.numerics.biginteger.divide.aspx 
  18. .EXAMPLE 
  19.     PSH [C:\foo]: . 'C:\Users\tfl\AppData\Local\Temp\Untitled7.ps1' 
  20.     Dividend: 680,564,693,277,057,719,623,408,366,969,033,850,880 
  21.     Divisor:  85,070,591,730,234,615,847,396,907,784,232,501,249 
  22.     Results: 
  23.        Using Divide method:     7 
  24.        Using Division operator: 7 
  25.        Using DivRem method:     7, remainder 85,070,551,165,415,408,691,630,012,479,406,342,137 
  26.  
  27.     Dividend: 90,612,345,123,875,509,091,827,560,007,100,099 
  28.     Divisor:  85,070,591,730,234,615,847,396,907,784,232,501,249 
  29.     Results: 
  30.        Using Divide method:     0 
  31.        Using Division operator: 0 
  32.        Using DivRem method:     0, remainder 90,612,345,123,875,509,091,827,560,007,100,099 
  33.      
  34.     Dividend: 1 
  35.     Divisor:  85,070,591,730,234,615,847,396,907,784,232,501,249 
  36.     Results: 
  37.        Using Divide method:     0 
  38.        Using Division operator: 0 
  39.        Using DivRem method:     0, remainder 1 
  40.      
  41.     Dividend: 19,807,040,619,342,712,359,383,728,129 
  42.     Divisor:  85,070,591,730,234,615,847,396,907,784,232,501,249 
  43.     Results: 
  44.        Using Divide method:     0 
  45.        Using Division operator: 0 
  46.        Using DivRem method:     0, remainder 19,807,040,619,342,712,359,383,728,129 
  47.   
  48.     Dividend: 85,070,591,730,234,615,847,396,907,784,232,501,250 
  49.     Divisor:  85,070,591,730,234,615,847,396,907,784,232,501,249 
  50.     Results:  
  51.        Using Divide method:     1 
  52.        Using Division operator: 1 
  53.        Using DivRem method:     1, remainder 1 
  54.   
  55. #> 
  56.  
  57. # Add namespace 
  58. $r = [system.Reflection.Assembly]::LoadWithPartialName("System.Numerics"
  59.  
  60. #Create a big integer divisor and an array of dividends 
  61. $divisor = [system.numerics.BigInteger]::pow([Int64]::MaxValue, 2) 
  62. $dividends = @() 
  63. $dividends += [system.numerics.BigInteger]::Multiply(([system.numerics.BigInteger] [system.Single]::MaxValue), 2) 
  64. $dividends += [system.numerics.BigInteger]::Parse("90612345123875509091827560007100099")  
  65. $dividends += [system.numerics.BigInteger]::One 
  66. $dividends += [system.numerics.BigInteger]::Multiply([Int32]::MaxValue, [Int64]::MaxValue) 
  67. $dividends += $divisor + [system.numerics.BigInteger]::One  
  68.   
  69. #Divide each dividend by divisor in three different ways 
  70. foreach ($dividend in $dividends) { 
  71.     "Dividend: {0:N0}" -f $dividend 
  72.     "Divisor:  {0:N0}" -f $divisor 
  73.     "Results:" 
  74.     "   Using Divide method:     {0:N0}" -f  [system.Numerics.BigInteger]::Divide($dividend, $divisor
  75.     "   Using Division operator: {0:N0}" -f ($dividend/$divisor
  76.     $remainder = [system.Numerics.BigInteger]::Zero 
  77.     $quotient = [system.numerics.BigInteger]::DivRem($dividend, $divisor, [ref] $remainder
  78.     "   Using DivRem method:     {0:N0}, remainder {1:N0}" -f $quotient, $remainder 
  79.     "" 
  80. }         

Sunday, 8 August 2010

Get-DriveInfo.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script gets and displays basic information about drives on a local system.  
  4. .DESCRIPTION 
  5.     This script uses the System.Io.DriveInfo's GetDrives method to get drive 
  6.     info which is then displayed.   This is a re-implementation of an MSDN 
  7.     sample. 
  8. .NOTES 
  9.     File Name  : Get-DriveInfo.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell Version 2.0 
  12. .LINK 
  13.     This script posted to: 
  14.         http://pshscripts.blogspot.com/2010/07/get-driveinfops1.html  
  15.     MSDN Sample posted at: 
  16.         http://msdn.microsoft.com/en-us/library/system.io.driveinfo.aspx 
  17.         http://msdn.microsoft.com/en-us/library/system.io.driveinfo.getdrives.aspx 
  18. .EXAMPLE 
  19.    PSH [C:\foo]: .\Get-DriveInfo.ps1' 
  20.    Drive C:\ 
  21.       File type: Fixed 
  22.       Volume label: 
  23.       File system: NTFS 
  24.       Available space to current user:           6.75 gb 
  25.       Total available space:                     6.75 gb 
  26.       Total size of drive:                     48.828 gb 
  27.    Drive D:\ 
  28.       File type: Fixed 
  29.       Volume label: 
  30.       File system: FAT32 
  31.       Available space to current user:           1.81 gb 
  32.       Total available space:                     1.81 gb 
  33.       Total size of drive:                      2.003 gb 
  34.       <ETC...> 
  35. #> 
  36.  
  37. # Get Drive Info 
  38. $allDrives = [system.Io.DriveInfo]::GetDrives() 
  39.  
  40. # Now display details 
  41. foreach ($d in $allDrives)  { 
  42.     "Drive {0}"        -f $d.Name 
  43.     "  File type: {0}" -f $d.DriveType 
  44.     if ($d.IsReady)  { 
  45.          "  Volume label: {0}" -f $d.VolumeLabel 
  46.          "  File system: {0}"  -f $d.DriveFormat 
  47.          $fs  = $d.AvailableFreeSpace/1gb 
  48.          $tfs = $d.TotalFreeSpace/1gb 
  49.          $TS  = $d.TotalSize/1gb 
  50.          "  Available space to current user:{0, 15:n2} gb" -f $fs 
  51.          "  Total available space:          {0, 15:n2} gb" -f $tfs 
  52.          "  Total size of drive:            {0, 15:n3} gb" -f $ts 
  53.     } 

Wednesday, 4 August 2010

Get-MultiplyBigInteger.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script re-implements this MSDN Sample of  
  4.     multiplying a big integer. 
  5. .DESCRIPTION 
  6.     This script first tries and fails to multiple a pair of large integers. The 
  7.     script catches the error and then used BigInteger.Multiply to multiply  
  8.     the two big itegers. 
  9. .NOTES 
  10.     File Name  : Get-MultiplyBigInteger.ps1 
  11.     Author     : Thomas Lee - tfl@psp.co.uk 
  12.     Requires   : PowerShell Version 2.0 
  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.numerics.biginteger.multiply.aspx 
  18. .EXAMPLE 
  19.     PSH [C:\foo]: .Get-MultiplyBigInteger.ps1 
  20.     Too big for long, try biginteger 
  21.     12,193,263,111,263,526,900 
  22. #> 
  23. # Add System.Numerics namespace 
  24. $r=[system.Reflection.Assembly]::LoadWithPartialName("System.Numerics"
  25.  
  26. # Two big numbers 
  27. $number1 = 1234567890 
  28. $number2 = 9876543210 
  29.  
  30. # Try normal [long] then catch error and do biginteger 
  31. try 
  32.    [long] $product = $number1 * $number2 
  33. catch  
  34. "Too big for long, try biginteger" 
  35.    $product = New-Object System.Numerics.BigInteger 
  36.    $product = [System.Numerics.BigInteger]::Multiply($number1, $number2
  37.    $product.ToString("N0"
  38. }    

Monday, 2 August 2010

Get-ConvertedTime.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script converts time using ConvertTime method.  
  4. .DESCRIPTION 
  5.     This script re-implements an MSDN sample. 
  6. .NOTES 
  7.     File Name  : Get-ConvertedTime.ps1 
  8.     Author     : Thomas Lee - tfl@psp.co.uk 
  9.     Requires   : PowerShell Version 2.0 
  10. .LINK 
  11.     This script posted to: 
  12.         http://pshscripts.blogspot.com/2010/08/get-convertedtimeps1.html
  13.     MSDN Sample posted at: 
  14.         http://msdn.microsoft.com/en-us/library/bb382835.aspx  
  15. .EXAMPLE 
  16.     PSH [C:\foo]: .\Get-ConvertedTime.ps1 
  17.     Local time zone: (GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London 
  18.  
  19.     Converted 1/1/2010 12:01:00 AM Unspecified to 12/31/2009 07:01:00 PM 
  20.     Converted 1/1/2010 12:01:00 AM Utc to 12/31/2009 07:01:00 PM 
  21.     Converted 1/1/2010 12:01:00 AM Local to 12/31/2009 07:01:00 PM 
  22.     Converted 11/6/2010 11:30:00 PM Unspecified to 11/6/2010 07:30:00 PM 
  23.     Converted 11/7/2010 02:30:00 AM Unspecified to 11/6/2010 10:30:00 PM 
  24. #> 
  25. #Create an array of times to convert 
  26. [DateTime[]] $times = (New-Object system.dateTime 2010, 1, 1, 0, 1, 0),  
  27.                       (New-Object system.DateTime(2010, 1, 1, 0, 1, 0, [System.DateTimeKind]::Utc)),  
  28.                       (New-Object system.dateTime(2010, 1, 1, 0, 1, 0, [System.DateTimeKind]::Local)),                             
  29.                       (New-Object system.DateTime(2010, 11, 6, 23, 30, 0)), 
  30.                       (New-Object system.DateTime(2010, 11, 7, 2, 30, 0) ); 
  31.  
  32. # Retrieve the time zone for Eastern Standard Time (U.S. and Canada). 
  33. try { 
  34.   $Est = [System.TimeZoneInfo]::FindSystemTimeZoneById("Eastern Standard Time"); 
  35. catch { 
  36.   "Unable to retrieve the Eastern Standard time zone." 
  37.   return
  38.  
  39. #  Display the current time zone name. 
  40. "Local time zone: {0}`n" -f [system.TimeZoneInfo]::Local.DisplayName 
  41.  
  42. # Convert and display each time in the $times array 
  43.  foreach ($timeToConvert in $times)  { 
  44.   $TargetTime = [System.TimeZoneInfo]::ConvertTime($TimeToConvert, $Est
  45.   "Converted {0} {1} to {2}" -f $timeToConvert,$timeToConvert.Kind, $targetTime 
  46. }                         

Sunday, 1 August 2010

Get-BigIntegerProperties.ps1


  1. <# 
  2. .SYNOPSIS 
  3.     This script displays dynamic properties of a BigInteger  
  4. .DESCRIPTION 
  5.     This script demonstates the properties on an instance of BigInteger 
  6. .NOTES 
  7.     File Name  : Get-BigIntegerProperties.ps1 
  8.     Author     : Thomas Lee - tfl@psp.co.uk 
  9.     Requires   : PowerShell Version 2.0 
  10.                  .NET Framework 4    
  11. .LINK 
  12.     This script posted to: 
  13.         http://www.pshscripts.blogspot.com 
  14.     MSDN Sample posted at: 
  15.         http://msdn.microsoft.com/en-us/library/system.numerics.biginteger_properties.aspx 
  16. .EXAMPLE 
  17.     PSH [c:\foo]: .\Get-BigIntegerProperties.ps1 
  18.     Big Integer from 4096: 
  19.  
  20.     IsPowerOfTwo : True 
  21.     IsZero       : False 
  22.     IsOne        : False 
  23.     IsEven       : True 
  24.     Sign         : 1 
  25. #> 
  26.  
  27. # Add the .NET Version 4 System.Numerics.DLL 
  28. Add-Type -Path "C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Numerics.dll" 
  29.  
  30. # Create a big integer then display it's key properties 
  31. $BigInt = New-object System.Numerics.BigInteger 4096 
  32. "Big Integer from 4096:" 
  33. $BigInt | fl *