Forum Discussion
get report of documents in SP site according to last accessed time/created by whom/last viewed time
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.
- Test SharePointSep 12, 2018Brass Contributor
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-GridViewThe 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 : InvokeMethodOnNullI 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- spucelikSep 12, 2018
Microsoft
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.
- Test SharePointSep 12, 2018Brass Contributor
Apologies, I had changed it. this is the error i am receiving after inserting the URL and document library URL: