开发者

Help with Windows PowerShell

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


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()}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜