Get-Stack


posted by ps3
07-24-2009

Downloads: 389
File size: 805 B
Views: 2,339

Embed
Get-Stack
  1. <# 
  2. .SYNOPSIS 
  3.     Demonstrates basic functions of a stack 
  4. .DESCRIPTION 
  5.     This script creates a stack, pushes three 
  6.     objects onto the stack, then displays the stack 
  7. .NOTES 
  8.     File Name  : Get-Stack.ps1 
  9.     Author     : Thomas Lee - tfl@psp.co.uk 
  10.     Requires   : PowerShell V2 CTP3 
  11.     Tags       : system.collections.stack,push 
  12. .LINK 
  13.     http://pshscripts.blogspot.com/2008/07/get-stackps1.html 
  14. .EXAMPLE 
  15.     PSH [C:\foo]: .\get-stack.ps1
  16.     myStack 
  17.     Count:    
  18.     Values: 
  19.     ! 
  20.     World 
  21.     Hello 
  22. #> 
  23.  
  24. ## 
  25. #  Start of script 
  26. ## 
  27.  
  28. $myStack = new-object  System.Collections.Stack  
  29. $myStack.Push("Hello"
  30. $myStack.Push("World"
  31. $myStack.Push("!"
  32.  
  33. # Display the properties and values of the Stack 
  34. "myStack" 
  35. "Count:    {0}" -f $myStack.Count 
  36. "Values:" 
  37. $mystack 
  38. # End Script 

This script creates a stack, pushes three objects onto the stack, then displays the stack.

Attributed to: Thomas Lee

URL: http://pshscripts.blogspot.com/2008/07/get-stackps1.html

Copyright 2012 PowerShell.com. All rights reserved.