private PSObject GetItemAsPSObject(object item, Path path) { if (item == null) { throw new Exception("Item can't be null"); } PSObject psObject = PSObject.AsPSObject(item); PSObject obj3 = item as PSObject; if (obj3 != null) { psObject.TypeNames.Clear(); foreach (string str in obj3.TypeNames) { psObject.TypeNames.Add(str); } } // Add full path as a property string providerFullPath = PathIntrinsics.GetFullProviderPath(ProviderInfo, path); psObject.Properties.Add(new PSNoteProperty("PSPath", providerFullPath)); NavigationCmdletProvider provider = this as NavigationCmdletProvider; if ((provider != null) && (path != null)) { string parentPath = null; if (PSDriveInfo == null) { parentPath = provider.GetParentPath(path, string.Empty, ProviderRuntime); } else { parentPath = provider.GetParentPath(path, PSDriveInfo.Root, ProviderRuntime); } if (!string.IsNullOrEmpty(parentPath)) { parentPath = PathIntrinsics.GetFullProviderPath(ProviderInfo, parentPath); } else { parentPath = string.Empty; } psObject.Properties.Add(new PSNoteProperty("PSParentPath", parentPath)); string childName = provider.GetChildName(path, ProviderRuntime); psObject.Properties.Add(new PSNoteProperty("PSChildName", childName)); } if (PSDriveInfo != null) { psObject.Properties.Add(new PSNoteProperty("PSDrive", PSDriveInfo)); } psObject.Properties.Add(new PSNoteProperty("PSProvider", ProviderInfo)); return(psObject); }