Monday 5 January 2009

Get-System.EnvironmentsStaticProperties1.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     Demonstrates the static properties on System.Environment 
  4. .DESCRIPTION 
  5.     This script uses the System.Environment class to retrieve interesting 
  6.     information about your system. The fields returned are static fields  
  7.     on the System.Environment class. 
  8. .NOTES 
  9.     File Name  : Get-System.EnvironmentStaticProperties1.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell V2 CTP3 
  12. .LINK 
  13.     http://www.pshscripts.blogspot.com 
  14. .EXAMPLE 
  15.     PS c:\Foo> .\Get-System.EnvironmentStaticProperties1.ps1 
  16.     Static properties in [System.Environment] 
  17.        TypeName: System.Environment 
  18.  
  19.     Name               MemberType Definition 
  20.     ----               ---------- ---------- 
  21.     CommandLine        Property   static System.String CommandLine {get;} 
  22.     CurrentDirectory   Property   static System.String CurrentDirectory {get;set;} 
  23.     ExitCode           Property   static System.Int32 ExitCode {get;set;} 
  24.     HasShutdownStarted Property   static System.Boolean HasShutdownStarted {get;} 
  25.     MachineName        Property   static System.String MachineName {get;} 
  26.     NewLine            Property   static System.String NewLine {get;} 
  27.     OSVersion          Property   static System.OperatingSystem OSVersion {get;} 
  28.     ProcessorCount     Property   static System.Int32 ProcessorCount {get;} 
  29.     StackTrace         Property   static System.String StackTrace {get;} 
  30.     SystemDirectory    Property   static System.String SystemDirectory {get;} 
  31.     TickCount          Property   static System.Int32 TickCount {get;} 
  32.     UserDomainName     Property   static System.String UserDomainName {get;} 
  33.     UserInteractive    Property   static System.Boolean UserInteractive {get;} 
  34.     UserName           Property   static System.String UserName {get;} 
  35.     Version            Property   static System.Version Version {get;} 
  36.     WorkingSet         Property   static System.Int64 WorkingSet {get;} 
  37.      
  38.     Static Property values for [System.Environment] 
  39.     CommandLine:       : "C:\Users\tfl\Desktop\psp\PowerShellPlus.exe" 
  40.     CurrentDirectory   : C:\Users\tfl\Desktop\psp 
  41.     ExitCode           : 0 
  42.     HasShutdownStarted : False 
  43.     MchineName         : 
  44.     NewLine            : 
  45.  
  46.  
  47.     OSVersion          : Microsoft Windows NT 6.0.6001 Service Pack 1 
  48.     ProcessorCount     : 8 
  49.     SystemDirctory     : C:\Windows\system32 
  50.     TickCount          : 261135752 
  51.     UserDomainName     : COOKHAM 
  52.     UserInteractive    : True 
  53.     UserName           : tfl 
  54.     Version            : 2.0.50727.1434 
  55.  
  56.     Stack Trace 
  57.             { Snipped - Left as an exercise for the reader...} 
  58. #> 
  59.  
  60. ### 
  61. #  Start Script 
  62. ## 
  63.  
  64. # Get and display statics in system.environment class 
  65. "Static properties in [System.Environment]" 
  66. [System.Environment] | Get-Member -Static -MemberType properties 
  67.  
  68. # Now display the values of the simple static properties 
  69. "";"Static Property values for [System.Environment]" 
  70. "CommandLine:       : {0}" -f [System.Environment]::CommandLine 
  71. "CurrentDirectory   : {0}" -f [System.Environment]::CurrentDirectory 
  72. "ExitCode           : {0}" -f [System.Environment]::ExitCOde 
  73. "HasShutdownStarted : {0}" -f [System.Environment]::HasShutdownStarted 
  74. "MchineName         : {0}" -f [System.Environment]::MachineNam 
  75. "NewLine            : {0}" -f [System.Environment]::NewLine 
  76. "OSVersion          : {0}" -f [System.Environment]::OSVersion 
  77. "ProcessorCount     : {0}" -f [System.Environment]::ProcessorCount 
  78. "SystemDirctory     : {0}" -f [System.Environment]::SystemDirectory 
  79. "TickCount          : {0}" -f [System.Environment]::TickCount 
  80. "UserDomainName     : {0}" -f [System.Environment]::UserDomainName 
  81. "UserInteractive    : {0}" -f [System.Environment]::UserInteractive 
  82. "UserName           : {0}" -f [System.Environment]::UserName 
  83. "Version            : {0}" -f [System.Environment]::Version 
  84. "WorkingSet         : {0}" -f [System.Environment]::WorkingSet   
  85.  
  86. # Here is the stack trace: 
  87. "";"Stack Trace:" 
  88. [System.Environment]::StackTrace 
  89. # End of Script 

No comments: