public static EntityDrive GetEntityDriveFromPSPath(PathIntrinsics pathIntrinsics, string path) { var paths = pathIntrinsics.GetResolvedPSPathFromPSPath(path); var drive = (from p in paths let e = p.Drive as EntityDrive where null != e select e).Distinct().FirstOrDefault(); return(drive); }