get-content to variable

Author Message
termor

  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 9/1/2007
  • Status: offline
get-content to variable Saturday, September 01, 2007 10:23 PM (permalink)
0
hello
  $obj = Get-ChildItem *.html
  foreach($file in $obj)
 {
 [string]$rez;
 get-content $file | $rez
 #do somethings with #rez
 
 }
 


I want write file content to $rez but this line give me error:
 Expressions are only permitted as the first element of a pipeline.
 At line:2 char:17
 + get-content $file | $rez
  <<<< }
 

 
#1
    SAPIENScripter

    • Total Posts : 283
    • Scores: 2
    • Reward points : 0
    • Joined: 11/1/2006
    • Location: SAPIEN Technologies
    • Status: offline
    RE: get-content to variable Tuesday, September 04, 2007 12:39 AM (permalink)
    0
    You need to do something like this:

    foreach ($file in $obj) {
    $rez=get-content $file
    $rez.length
    }
    Jeffery Hicks
    Windows PowerShell MVP
    SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com

    Follow Me: http://www.twitter.com/JeffHicks
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9