How to find the usable Methods?

Hi,
I am new to this, I’m working on a code that lists every name of every file in a folder, I’ve found the solution on Google but I still can’t figure out how he found the .Fullname method? Where can I find more about these methods? I’ve tried “Help Write-Host | GM” and "help $file | gm "but none give the desired answer to see the method “.FullName” , I want to find more about this so I can test more.

The line I’m talking about is “write-host $file.FullName”

the code is:

Set-Location C:\mystuff

$files = Get-ChildItem -Recurse
foreach($file in $files)
{
write-host $file.FullName
}

Using Get-Member is the right way to figure out what methods and properties an object has. Just run

Get-ChildItem | Get-Member

and you will see all of them listed.

In this case .FullName is not a method - it’s a property. And it’s a property of the type [System.IO.FileInfo] or [System.IO.DirectoryInfo].

You can distinguish them easily by their names. Mathods always have parenthesis at the end, properties don’t.

1 Like

thank you for the answer! How did you find out what type it is? Did you consult microsoft docs or did you use a Powershell command?

Did you run the code snippet I suggested and inspected the output? :wink:

You’re right, I was checking at the bottom. Thank you!