views:

29

answers:

1

I'm trying to access a method of text file, I use this first:

Get-Item file.txt | get-member

Then I would like to use the GetType() method, but it says it doesn't recognize file.txt as the name of a cmdlet,function,script file or operable problem. I need to access that or any other method :D

+3  A: 

You have a couple of options here. First is to turn the command into an expression by using parens:

(Get-Item file.txt).GetType()

The other option is to use Foreach-Object (aliased to foreach) in the pipeline to execute arbitrary script against pipeline objects where each pipeline object is represented by the special variable $_ e.g.:

Get-Item file.txt | Foreach {$_.GetType()}
Keith Hill
thank you! it worked :D
Osukaa