Home

get report of documents in SP site according to last accessed time/created by whom/last viewed time

%3CLINGO-SUB%20id%3D%22lingo-sub-251798%22%20slang%3D%22en-US%22%3Eget%20report%20of%20documents%20in%20SP%20site%20according%20to%20last%20accessed%20time%2Fcreated%20by%20whom%2Flast%20viewed%20time%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-251798%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20to%26nbsp%3Bget%20report%20of%20documents%20in%20a%20particular%20SP%20site%20(with%20their%20URLS)%20according%20to%20last%20accessed%20time%2Fcreated%20by%20whom%2Flast%20viewed%20time.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20running%20a%20custom%20report%20and%20got%20the%20most%20popular%20items%20list%20however%20it%20does%20not%20have%20complete%20data.%3C%2FP%3E%3CP%3Ecan%20someone%20please%20assist%20in%20this%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-251798%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFiles%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Server%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESites%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EUsage%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-252368%22%20slang%3D%22en-US%22%3ERe%3A%20get%20report%20of%20documents%20in%20SP%20site%20according%20to%20last%20accessed%20time%2Fcreated%20by%20whom%2Flast%20viewed%20t%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-252368%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20running%20windows%20powershell%20ISE%20as%20an%20administrator%20and%20get%20the%20following%20error%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGet-SPWeb%20%3A%20Cannot%20find%20an%20SPSite%20object%20that%20contains%20the%20following%20Id%20or%20Url%3A%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fabc.com%3Dhttps%3A%2F%2Fabc.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fabc.com%3Dhttps%3A%2F%2Fabc.com%3C%2FA%3E.%3CBR%20%2F%3EAt%20line%3A8%20char%3A10%3CBR%20%2F%3E%2B%20%24SPWeb%20%3D%20Get-SPWeb%20%24siteUrl%3D%22%3CA%20href%3D%22https%3A%2F%2Fabc.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fabc.com%3C%2FA%3E%22%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20InvalidData%3A%20(Microsoft.Share....SPCmdletGetWeb%3ASPCmdletGetWeb)%20%5BGet-SPWeb%5D%2C%20SPCmdletPi%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CBR%20%2F%3EpeBindException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20Microsoft.SharePoint.PowerShell.SPCmdletGetWeb%3CBR%20%2F%3E%3CBR%20%2F%3ESPWeb.Title%3CBR%20%2F%3ECannot%20index%20into%20a%20null%20array.%3CBR%20%2F%3EAt%20line%3A10%20char%3A9%3CBR%20%2F%3E%2B%20%24List%20%3D%20%24SPWeb.lists%5B%24documentLibrary%5D%20%3D%20%22Auditing%22%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20InvalidOperation%3A%20(%3A)%20%5B%5D%2C%20RuntimeException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20NullArray%3CBR%20%2F%3E%3CBR%20%2F%3EYou%20cannot%20call%20a%20method%20on%20a%20null-valued%20expression.%3CBR%20%2F%3EAt%20line%3A53%20char%3A1%3CBR%20%2F%3E%2B%20%24SPWeb.Dispose()%3B%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20InvalidOperation%3A%20(%3A)%20%5B%5D%2C%20RuntimeException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20InvokeMethodOnNull%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-251912%22%20slang%3D%22en-US%22%3ERe%3A%20get%20report%20of%20documents%20in%20SP%20site%20according%20to%20last%20accessed%20time%2Fcreated%20by%20whom%2Flast%20viewed%20t%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-251912%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F49601i77BA56E8BD719250%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-251907%22%20slang%3D%22en-US%22%3ERe%3A%20get%20report%20of%20documents%20in%20SP%20site%20according%20to%20last%20accessed%20time%2Fcreated%20by%20whom%2Flast%20viewed%20t%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-251907%22%20slang%3D%22en-US%22%3EYes%2C%20I%20tried%20it%20with%20the%20root%20Site%20URL%20too%20however%20it%20gives%20the%20same%20error.%3CBR%20%2F%3EI%20have%20also%20entered%20the%20correct%20name%20of%20library%20from%20library%20settings%20still%20the%20same%20issue%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-251906%22%20slang%3D%22en-US%22%3ERe%3A%20get%20report%20of%20documents%20in%20SP%20site%20according%20to%20last%20accessed%20time%2Fcreated%20by%20whom%2Flast%20viewed%20t%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-251906%22%20slang%3D%22en-US%22%3E%3CP%3ETypically%20this%20means%20that%20the%20URL%20it%20not%20to%20a%20site.%26nbsp%3B%20Make%20sure%20it's%20going%20to%20the%20site%20level%20and%20not%20any%20deeper.%26nbsp%3B%20For%20example%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESite%20%3D%20http%3A%2F%2Fsharepoint%2Fsites%2Fhr%20is%20the%20root%20of%20the%20HR%20site%3C%2FP%3E%0A%3CP%3EWithin%20that%20site%20will%20be%20the%20name%20of%20the%20library.%26nbsp%3B%20Use%20the%20name%20that%20is%20in%20Library%20Setttngs%20and%20not%20the%20URL.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-251905%22%20slang%3D%22en-US%22%3ERe%3A%20get%20report%20of%20documents%20in%20SP%20site%20according%20to%20last%20accessed%20time%2Fcreated%20by%20whom%2Flast%20viewed%20t%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-251905%22%20slang%3D%22en-US%22%3E%3CP%3EApologies%2C%20I%20had%20changed%20it.%20this%20is%20the%20error%20i%20am%20receiving%20after%20inserting%20the%20URL%20and%20document%20library%20URL%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F49600i7171C0C6E836CAE0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-251902%22%20slang%3D%22en-US%22%3ERe%3A%20get%20report%20of%20documents%20in%20SP%20site%20according%20to%20last%20accessed%20time%2Fcreated%20by%20whom%2Flast%20viewed%20t%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-251902%22%20slang%3D%22en-US%22%3E%3CP%3Ethe%20GetAllDocInventoryWithVersion%20statement%20is%20simply%20calling%20the%20function%20with%20the%20specified%20parameters.%26nbsp%3B%20Replace%20%22https%3A%2F%2FSharePoint2013%22%20with%20your%20site%20that%20contains%20the%20document%20library.%26nbsp%3B%20Also%20replace%20%22Program%20Management%22%20with%20the%20name%20of%20the%20document%20library.%26nbsp%3B%20It%20should%20work%20then.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-251899%22%20slang%3D%22en-US%22%3ERe%3A%20get%20report%20of%20documents%20in%20SP%20site%20according%20to%20last%20accessed%20time%2Fcreated%20by%20whom%2Flast%20viewed%20t%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-251899%22%20slang%3D%22en-US%22%3E%3CP%3Ethanks%20for%20your%20response.%20i%20got%20the%20most%20of%20the%20errors%20removed.%20i%20am%20running%20this%20on%20Sp%20server%20however%20the%20only%20error%20remaining%20no%20is%20for%20the%20last%20command%3A%3CBR%20%2F%3EGetAllDocInventoryWithVersion%20%22https%3A%2F%2FSharePoint2013%22%20%22Program%20Management%22%7C%20Out-GridView%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20error%3A%3C%2FP%3E%3CP%3EGet-SPWeb%20%3A%20Cannot%20find%20an%20SPSite%20object%20that%20contains%20the%20following%20Id%20or%20Url%3A%3CBR%20%2F%3Ehttps%3A%2F%2FSharePoint2013%3D%3CA%20href%3D%22http%3A%2F%2Fabc.com%2Fxyz%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fabc.com%2Fxyz%3C%2FA%3E.%3CBR%20%2F%3EAt%20line%3A8%20char%3A10%3CBR%20%2F%3E%2B%20%24SPWeb%20%3D%20Get-SPWeb%20%24siteUrl%3D%22%3CA%20href%3D%22http%3A%2F%2Fabc.com%2Fxyz%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fabc.com%2Fxyz%3C%2FA%3E%22%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20InvalidData%3A%20(Microsoft.Share....SPCmdletGetWeb%3ASPCmdletGetWeb)%20%5BGet-SPWeb%5D%2C%20SPCmdletPi%3CBR%20%2F%3EpeBindException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20Microsoft.SharePoint.PowerShell.SPCmdletGetWeb%3CBR%20%2F%3E%3CBR%20%2F%3ESPWeb.Title%3CBR%20%2F%3ECannot%20index%20into%20a%20null%20array.%3CBR%20%2F%3EAt%20line%3A10%20char%3A9%3CBR%20%2F%3E%2B%20%24List%20%3D%20%24SPWeb.lists%5B%24documentLibrary%5D%20%3D%20%22SSRS%20Reporting%22%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20InvalidOperation%3A%20(%3A)%20%5B%5D%2C%20RuntimeException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20NullArray%3CBR%20%2F%3E%3CBR%20%2F%3EYou%20cannot%20call%20a%20method%20on%20a%20null-valued%20expression.%3CBR%20%2F%3EAt%20line%3A53%20char%3A1%3CBR%20%2F%3E%2B%20%24SPWeb.Dispose()%3B%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20InvalidOperation%3A%20(%3A)%20%5B%5D%2C%20RuntimeException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20InvokeMethodOnNull%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20also%20tried%20the%20following%20command%3A%3C%2FP%3E%3CP%3EGet-AllDocInventoryWithVersion%20%22%3CA%20href%3D%22http%3A%2F%2Fabc.com%2Fxyz%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fabc.com%2Fxyz%3C%2FA%3E%22%20%7C%20Export-Csv%20-NoTypeInformation%20-Path%20%22C%3A%5CUsers%5CDesktop%5Csitecollectionreport.csv%22%3CBR%20%2F%3E%3CBR%20%2F%3Ethe%20error%3A%3C%2FP%3E%3CP%3EGet-AllDocInventoryWithVersion%20%3A%20The%20term%20'Get-AllDocInventoryWithVersion'%20is%20not%20recognized%20as%20the%20name%20of%20a%20cmdlet%2C%3CBR%20%2F%3Efunction%2C%20script%20file%2C%20or%20operable%20program.%20Check%20the%20spelling%20of%20the%20name%2C%20or%20if%20a%20path%20was%20included%2C%20verify%20that%3CBR%20%2F%3Ethe%20path%20is%20correct%20and%20try%20again.%3CBR%20%2F%3EAt%20line%3A57%20char%3A1%3CBR%20%2F%3E%2B%20Get-AllDocInventoryWithVersion%20%22%3CA%20href%3D%22http%3A%2F%2Fabc.com%2Fxyz%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fabc.com%2Fxyz%3C%2FA%3E%20...%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20ObjectNotFound%3A%20(Get-AllDocInventoryWithVersion%3AString)%20%5B%5D%2C%20CommandNotFoundException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20CommandNotFoundException%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-251895%22%20slang%3D%22en-US%22%3ERe%3A%20get%20report%20of%20documents%20in%20SP%20site%20according%20to%20last%20accessed%20time%2Fcreated%20by%20whom%2Flast%20viewed%20t%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-251895%22%20slang%3D%22en-US%22%3E%3CP%3EI%20was%20able%20to%20paste%20the%20exact%20code%20below%20and%20run%20it%20successfully.%26nbsp%3B%20Make%20sure%20you're%20running%20this%20from%20the%20SharePoint%20server%20where%20it%20has%20access%20to%20the%20SharePoint%20dll's.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-251851%22%20slang%3D%22en-US%22%3ERe%3A%20get%20report%20of%20documents%20in%20SP%20site%20according%20to%20last%20accessed%20time%2Fcreated%20by%20whom%2Flast%20viewed%20t%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-251851%22%20slang%3D%22en-US%22%3E%3CP%3EHey%20got%20the%20following%20errors%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAt%20line%3A2%20char%3A20%3CBR%20%2F%3E%2B%20%24SPWeb%20%3D%20Get-SPWeb%20%24%3CA%20href%3D%22http%3A%2F%2Fabc.com%2Fxyz%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fabc.com%2Fxyz%3C%2FA%3E%20%23Change%3CBR%20%2F%3Ethe%20...%3CBR%20%2F%3E%2B%20~~~~~~%3CBR%20%2F%3EVariable%20reference%20is%20not%20valid.%20'%3A'%20was%20not%20followed%20by%20a%20valid%20variable%20name%3CBR%20%2F%3Echaracter.%20Consider%20using%20%24%7B%7D%20to%20delimit%20the%20name.%3CBR%20%2F%3EAt%20line%3A4%20char%3A28%3CBR%20%2F%3E%2B%20%24List%20%3D%20%24SPWeb.Lists%5B%24Test's%20Excel%20Reporting%5D%20%23Change%20the%20document%20library%3CBR%20%2F%3Ename%20...%3CBR%20%2F%3E%2B%3CBR%20%2F%3E~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3EThe%20string%20is%20missing%20the%20terminator%3A%20'.%3CBR%20%2F%3EAt%20line%3A4%20char%3A28%3CBR%20%2F%3E%2B%20%24List%20%3D%20%24SPWeb.Lists%5B%24Test's%20Excel%20Reporting%5D%20%23Change%20the%20document%20library%3CBR%20%2F%3Ename%20...%3CBR%20%2F%3E%2B%20~%3CBR%20%2F%3EMissing%20'%5D'%20after%20array%20index%20expression.%3CBR%20%2F%3EAt%20line%3A4%20char%3A28%3CBR%20%2F%3E%2B%20%24List%20%3D%20%24SPWeb.Lists%5B%24Test's%20Excel%20Reporting%5D%20%23Change%20the%20document%20library%3CBR%20%2F%3Ename%20...%3CBR%20%2F%3E%2B%3CBR%20%2F%3E~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3EUnexpected%20token%20''s%20Excel%20Reporting%5D%20%23Change%20the%20document%20library%20name%20here%23%3CBR%20%2F%3E%24ItemsColl%20%3D%20%24List.Items%3CBR%20%2F%3E%24tableau%20%3D%40()%3B'%20in%20expression%20or%20statement.%3CBR%20%2F%3EAt%20line%3A1%20char%3A76%3CBR%20%2F%3E%2B%20function%20GetAllDocInventoryWithVersion(%5Bstring%5D%24siteUrl%2C%20%24documentLibrary)%20%7B%3CBR%20%2F%3E%2B%20~%3CBR%20%2F%3EMissing%20closing%20'%7D'%20in%20statement%20block.%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20ParserError%3A%20(%3A)%20%5B%5D%2C%20ParentContainsErrorRecordEx%3CBR%20%2F%3Eception%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20InvalidVariableReferenceWithDrive%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20cannot%20call%20a%20method%20on%20a%20null-valued%20expression.%3CBR%20%2F%3EAt%20line%3A1%20char%3A1%3CBR%20%2F%3E%2B%20%24SPWeb.Dispose()%3B%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20InvalidOperation%3A%20(%3A)%20%5B%5D%2C%20RuntimeException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20InvokeMethodOnNull%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EAt%20line%3A1%20char%3A1%3CBR%20%2F%3E%2B%20%7D%3CBR%20%2F%3E%2B%20~%3CBR%20%2F%3EUnexpected%20token%20'%7D'%20in%20expression%20or%20statement.%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20ParserError%3A%20(%3A)%20%5B%5D%2C%20ParentContainsErrorRecordEx%3CBR%20%2F%3Eception%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20UnexpectedToken%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EGetAllDocInventoryWithVersion%20%3A%20The%20term%20'GetAllDocInventoryWithVersion'%20is%3CBR%20%2F%3Enot%20recognized%20as%20the%20name%20of%20a%20cmdlet%2C%20function%2C%20script%20file%2C%20or%20operable%3CBR%20%2F%3Eprogram.%20Check%20the%20spelling%20of%20the%20name%2C%20or%20if%20a%20path%20was%20included%2C%20verify%3CBR%20%2F%3Ethat%20the%20path%20is%20correct%20and%20try%20again.%3CBR%20%2F%3EAt%20line%3A1%20char%3A1%3CBR%20%2F%3E%2B%20GetAllDocInventoryWithVersion%20%22https%3A%2F%2FSharePoint2013%22%20%22Program%20Management%22%7C%3CBR%20%2F%3EOut%20...%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20ObjectNotFound%3A%20(GetAllDocInventoryWithVersion%3AS%3CBR%20%2F%3Etring)%20%5B%5D%2C%20CommandNotFoundException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20CommandNotFoundException%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-251823%22%20slang%3D%22en-US%22%3ERe%3A%20get%20report%20of%20documents%20in%20SP%20site%20according%20to%20last%20accessed%20time%2Fcreated%20by%20whom%2Flast%20viewed%20t%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-251823%22%20slang%3D%22en-US%22%3E%3CP%3EAwesome.%20will%20try%20this%20out.%20thanks!!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-251820%22%20slang%3D%22en-US%22%3ERe%3A%20get%20report%20of%20documents%20in%20SP%20site%20according%20to%20last%20accessed%20time%2Fcreated%20by%20whom%2Flast%20viewed%20t%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-251820%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20PowerShell%20script%20should%20do%20it.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3Eif((Get-PSSnapin%20%7C%20Where%20%7B%24_.Name%20-eq%20%22Microsoft.SharePoint.PowerShell%22%7D)%20-eq%20%24null)%20%0A%7B%0A%20Add-PSSnapin%20Microsoft.SharePoint.PowerShell%3B%0A%7D%0A%0Afunction%20GetAllDocInventoryWithVersion(%5Bstring%5D%24siteUrl%2C%20%24documentLibrary)%20%7B%0A%0A%24SPWeb%20%3D%20Get-SPWeb%20%24siteUrl%20%23Change%20the%20SharePoint%20site%20name%20here%23%0Awrite-host%20SPWeb.Title%0A%24List%20%3D%20%24SPWeb.Lists%5B%24documentLibrary%5D%20%23Change%20the%20document%20library%20name%20here%23%0A%24ItemsColl%20%3D%20%24List.Items%0A%24tableau%20%3D%40()%3B%0A%0Aforeach%20(%24item%20in%20%24ItemsColl)%20%0A%7B%0A%20%20%20%20%24itemFileSize%20%3D%20%24item.File.Length%2F1KB%0A%20%20%20%20%24o%20%3D%20new-object%20psobject%0A%20%20%0A%20%20%20%20%24o%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22ItemID%22%20-value%20%24item.ID%3B%0A%20%20%20%20%24o%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Item%20Title%22%20-value%20%24item.Title%3B%0A%20%20%20%20%24o%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Version%22%20-value%20%20%22%22%3B%23%24item.Versions.Count%3B%0A%20%20%20%20%24o%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Item%20URL%22%20-value%20%24item.Url%3B%20%20%20%20%0A%20%20%20%20%24o%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Comments%22%20-value%20%20%24item.CheckInComment%3B%0A%20%20%20%20%24o%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22File%20Size%20(KB)%22%20-value%20%24itemFileSize%20%3B%0A%20%20%20%20%24o%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Created%20Date%22%20-value%20%24item%5B%22Created%22%5D%0A%20%20%20%20%24o%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Created%20By%22%20-value%20%24item%5B%22Author%22%5D%0A%20%20%20%20%24o%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Modifed%20Date%22%20-value%20%24item%5B%22Created%22%5D%0A%20%20%20%20%24o%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Modifed%20By%22%20-value%20%24item%5B%22Editor%22%5D%0A%20%20%20%20%24tableau%20%2B%3D%20%24o%3B%0A%20%20%20%20%0A%20%20%20%20foreach(%24Ver%20in%20%24item.Versions)%0A%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%24verFileSize%20%3D%20%24item.File.Versions.GetVersionFromLabel(%24Ver.VersionLabel).Size%2F1KB%0A%20%20%20%20%20%20%20%20%24v%20%3D%20new-object%20psobject%0A%20%20%20%20%20%20%20%20%24comment%20%3D%20%24item.File.Versions.GetVersionFromLabel(%24Ver.VersionLabel).CheckInComment%0A%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%24v%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22ItemID%22%20-value%20%24item.ID%3B%0A%20%20%20%20%20%20%20%20%24v%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Item%20Title%22%20-value%20%24item.Title%3B%0A%20%20%20%20%20%20%20%20%24v%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Version%22%20-value%20%20%24Ver.VersionLabel%3B%0A%20%20%20%20%20%20%20%20%24v%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Item%20URL%22%20-value%20%24Ver.Url%3B%0A%20%20%20%20%20%20%20%20%24v%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Comments%22%20-value%20%20%24comment%3B%20%20%20%20%0A%20%20%20%20%20%20%20%20%24v%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22File%20Size%20(KB)%22%20-value%20%24verFileSize%3B%0A%20%20%20%20%20%20%20%20%24v%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Created%20Date%22%20-value%20%24Ver%5B%22Created%22%5D%0A%20%20%20%20%20%20%20%20%24v%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Created%20By%22%20-value%20%24Ver%5B%22Author%22%5D%0A%20%20%20%20%20%20%20%20%24v%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Modifed%20Date%22%20-value%20%24Ver%5B%22Created%22%5D%0A%20%20%20%20%20%20%20%20%24v%20%7C%20Add-Member%20-MemberType%20noteproperty%20-Name%20%22Modifed%20By%22%20-value%20%24Ver%5B%22Editor%22%5D%0A%20%20%20%20%20%20%20%20%24tableau%20%2B%3D%20%24v%3B%0A%20%20%20%20%20%20%20%0A%20%20%20%20%20%7D%0A%7D%0A%0A%24SPWeb.Dispose()%3B%0A%23%24tableau%7C%20Out-GridView%0Areturn%20%24tableau%0A%7D%0A%0A%0A%0A%0A%0AGetAllDocInventoryWithVersion%20%22https%3A%2F%2FSharePoint2013%22%20%22Program%20Management%22%7C%20Out-GridView%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Highlighted
Test SharePoint
Contributor

Hello,

 

I want to get report of documents in a particular SP site (with their URLS) according to last accessed time/created by whom/last viewed time.

 

I tried running a custom report and got the most popular items list however it does not have complete data.

can someone please assist in this

 

thanks

11 Replies

This PowerShell script should do it.

 

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) 
{
	Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

function GetAllDocInventoryWithVersion([string]$siteUrl, $documentLibrary) {

$SPWeb = Get-SPWeb $siteUrl #Change the SharePoint site name here#
write-host SPWeb.Title
$List = $SPWeb.Lists[$documentLibrary] #Change the document library name here#
$ItemsColl = $List.Items
$tableau =@();

foreach ($item in $ItemsColl) 
{
    $itemFileSize = $item.File.Length/1KB
    $o = new-object psobject
  
    $o | Add-Member -MemberType noteproperty -Name "ItemID" -value $item.ID;
    $o | Add-Member -MemberType noteproperty -Name "Item Title" -value $item.Title;
    $o | Add-Member -MemberType noteproperty -Name "Version" -value  "";#$item.Versions.Count;
    $o | Add-Member -MemberType noteproperty -Name "Item URL" -value $item.Url;    
    $o | Add-Member -MemberType noteproperty -Name "Comments" -value  $item.CheckInComment;
    $o | Add-Member -MemberType noteproperty -Name "File Size (KB)" -value $itemFileSize ;
    $o | Add-Member -MemberType noteproperty -Name "Created Date" -value $item["Created"]
    $o | Add-Member -MemberType noteproperty -Name "Created By" -value $item["Author"]
    $o | Add-Member -MemberType noteproperty -Name "Modifed Date" -value $item["Created"]
    $o | Add-Member -MemberType noteproperty -Name "Modifed By" -value $item["Editor"]
    $tableau += $o;
    
    foreach($Ver in $item.Versions)
     {
        $verFileSize = $item.File.Versions.GetVersionFromLabel($Ver.VersionLabel).Size/1KB
        $v = new-object psobject
        $comment = $item.File.Versions.GetVersionFromLabel($Ver.VersionLabel).CheckInComment
           
        $v | Add-Member -MemberType noteproperty -Name "ItemID" -value $item.ID;
        $v | Add-Member -MemberType noteproperty -Name "Item Title" -value $item.Title;
        $v | Add-Member -MemberType noteproperty -Name "Version" -value  $Ver.VersionLabel;
        $v | Add-Member -MemberType noteproperty -Name "Item URL" -value $Ver.Url;
        $v | Add-Member -MemberType noteproperty -Name "Comments" -value  $comment;    
        $v | Add-Member -MemberType noteproperty -Name "File Size (KB)" -value $verFileSize;
        $v | Add-Member -MemberType noteproperty -Name "Created Date" -value $Ver["Created"]
        $v | Add-Member -MemberType noteproperty -Name "Created By" -value $Ver["Author"]
        $v | Add-Member -MemberType noteproperty -Name "Modifed Date" -value $Ver["Created"]
        $v | Add-Member -MemberType noteproperty -Name "Modifed By" -value $Ver["Editor"]
        $tableau += $v;
       
     }
}

$SPWeb.Dispose();
#$tableau| Out-GridView
return $tableau
}





GetAllDocInventoryWithVersion "https://SharePoint2013" "Program Management"| Out-GridView

Hey got the following errors:

 

At line:2 char:20
+ $SPWeb = Get-SPWeb $http://abc.com/xyz #Change
the ...
+ ~~~~~~
Variable reference is not valid. ':' was not followed by a valid variable name
character. Consider using ${} to delimit the name.
At line:4 char:28
+ $List = $SPWeb.Lists[$Test's Excel Reporting] #Change the document library
name ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: '.
At line:4 char:28
+ $List = $SPWeb.Lists[$Test's Excel Reporting] #Change the document library
name ...
+ ~
Missing ']' after array index expression.
At line:4 char:28
+ $List = $SPWeb.Lists[$Test's Excel Reporting] #Change the document library
name ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token ''s Excel Reporting] #Change the document library name here#
$ItemsColl = $List.Items
$tableau =@();' in expression or statement.
At line:1 char:76
+ function GetAllDocInventoryWithVersion([string]$siteUrl, $documentLibrary) {
+ ~
Missing closing '}' in statement block.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : InvalidVariableReferenceWithDrive

 

You cannot call a method on a null-valued expression.
At line:1 char:1
+ $SPWeb.Dispose();
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull


At line:1 char:1
+ }
+ ~
Unexpected token '}' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : UnexpectedToken


GetAllDocInventoryWithVersion : The term 'GetAllDocInventoryWithVersion' is
not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
+ GetAllDocInventoryWithVersion "https://SharePoint2013" "Program Management"|
Out ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (GetAllDocInventoryWithVersion:S
tring) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

 

I was able to paste the exact code below and run it successfully.  Make sure you're running this from the SharePoint server where it has access to the SharePoint dll's.

thanks for your response. i got the most of the errors removed. i am running this on Sp server however the only error remaining no is for the last command:
GetAllDocInventoryWithVersion "https://SharePoint2013" "Program Management"| Out-GridView

 

The error:

Get-SPWeb : Cannot find an SPSite object that contains the following Id or Url:
https://SharePoint2013=http://abc.com/xyz.
At line:8 char:10
+ $SPWeb = Get-SPWeb $siteUrl="http://abc.com/xyz"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Microsoft.Share....SPCmdletGetWeb:SPCmdletGetWeb) [Get-SPWeb], SPCmdletPi
peBindException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetWeb

SPWeb.Title
Cannot index into a null array.
At line:10 char:9
+ $List = $SPWeb.lists[$documentLibrary] = "SSRS Reporting"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray

You cannot call a method on a null-valued expression.
At line:53 char:1
+ $SPWeb.Dispose();
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

 

 

I also tried the following command:

Get-AllDocInventoryWithVersion "http://abc.com/xyz" | Export-Csv -NoTypeInformation -Path "C:\Users\Desktop\sitecollectionreport.csv"

the error:

Get-AllDocInventoryWithVersion : The term 'Get-AllDocInventoryWithVersion' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that
the path is correct and try again.
At line:57 char:1
+ Get-AllDocInventoryWithVersion "http://abc.com/xyz ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-AllDocInventoryWithVersion:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

the GetAllDocInventoryWithVersion statement is simply calling the function with the specified parameters.  Replace "https://SharePoint2013" with your site that contains the document library.  Also replace "Program Management" with the name of the document library.  It should work then.

Apologies, I had changed it. this is the error i am receiving after inserting the URL and document library URL:

image.png

Typically this means that the URL it not to a site.  Make sure it's going to the site level and not any deeper.  For example:

 

Site = http://sharepoint/sites/hr is the root of the HR site

Within that site will be the name of the library.  Use the name that is in Library Setttngs and not the URL.

Yes, I tried it with the root Site URL too however it gives the same error.
I have also entered the correct name of library from library settings still the same issue

I am running windows powershell ISE as an administrator and get the following error:

 

Get-SPWeb : Cannot find an SPSite object that contains the following Id or Url: 
https://abc.com=https://abc.com.
At line:8 char:10
+ $SPWeb = Get-SPWeb $siteUrl="https://abc.com"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Microsoft.Share....SPCmdletGetWeb:SPCmdletGetWeb) [Get-SPWeb], SPCmdletPi 
peBindException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetWeb

SPWeb.Title
Cannot index into a null array.
At line:10 char:9
+ $List = $SPWeb.lists[$documentLibrary] = "Auditing"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray

You cannot call a method on a null-valued expression.
At line:53 char:1
+ $SPWeb.Dispose();
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
35 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies