System._ComObject, which I'm assuming is set in that first command of the recurse functions. Is that not what Get-Childitem returns?
No. The COM objects returned from the scripting.filesystemobject are different types of objects then what you get from the Powershell File system provider. The Powershell provider basically is composed of .NET System.IO.FileInfo objects. While it may seem like they are the same, since they are both dealing with filesystem operations, the two types of objects are not compatible.
Microsoft does provide a document that suggest conversions.
In fact your script already uses a method to convert them, in one of your if conditionals. The bit where you do a get-item $i.path
. That code fragment basically converting one type of object to the other. It has Get-Item
return a powershell filesystem object, and to do that, you give the Get-Item command the full path of the returned by the scripting.filesystemobject value you have in $i
. You should be able to do this same trick in your other places as well.