Reputation: 7994
I started doing some powershell scripting today for my work and I can find this page: http://technet.microsoft.com/en-us/library/hh849827.aspx
This shows all the Cmdlets that I am using in the scripts, but I cannot find the documentation on how to use the returned objects of these Cmdlets. For example, I am using the Get-ChildItem cmd to get all the files in a dir recursively. Then I am using a ForEach loop like this:
$dest = "C:\Users\a-mahint\Documents\Testing\Dest"
$destlist = Get-ChildItem $dest -Recurse
foreach ($file in $destlist){
write-host "File: $file"
write-host $file
$result = test-path -path "C:\Users\a-mahint\Documents\Testing\Src\*" -include $file.Name
if (-not $result){
Copy-Item $file -Destination "$backup"
}
}
write-host "Done copying deleted files"
Except I have no idea what type of object a $file is...In the documentation above, it just says it outputs a System.Object, but that doesn't help at all. I want to know all the properties of this object so I can use them to debug.
Upvotes: 0
Views: 171
Reputation: 2166
From a question I asked one time Andy Arismendi supplied some links for me to read.
$file = Get-Item C:\foo.txt
Remember there is a $file | Get-Member
command you can use to view the objects methods and properties. Also since everything in PowerShell is an Object you can always do $file.GetType()
and then Bing that type.
Upvotes: 2
Reputation: 1
Here is a decent reference for get-childitem.
http://technet.microsoft.com/en-us/library/ee176841.aspx
What kind of file details are you needing exactly?
Upvotes: 0
Reputation: 2061
Get-ChildItem "C:\Windows\System32\WindowsPowerShell\v1.0\en-US" -Filter *.txt
Upvotes: 1