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.
$destis under c:\, which is a PSDrive which uses the file system provider. When you use Get-ChildItem with that type of provider, you get a sequence ofSystem.IO.FileSystemInfoobjects, eitherDirectoryInfoorFileInfodepending on whether each item is a directory or file.