Sunday, 29 January 2012

Error while configuring Usage Data Logging using Powershell

Hello again,

I was configuring Usage a Data Logging settings using powershell. These settings we can configure from either Central Admin (Central Admin >> Monitoring >>Configure usage and health data collection) or from PowerShell.

So I choose my all time favorite Powershell. I have executed the following command
Set-SPUsageService -LoggingEnabled 1 -UsageLogLocation F:\SharePoint Logs                                  -UsageLogMaxSpaceGB 2

Following are the options
LoggingEnabled: Enables usage data logging
UsageLogLocation: Path for Usage logs
UsageLogMaxSpaceGB: Maximum amount of drive space used for storing the logs

But I am getting following exception
Set-SPUsageService : Cannot bind parameter 'Identity'. Cannot convert value "Lo
gs1\" to type "Microsoft.SharePoint.PowerShell.SPUsageServicePipeBind". Error:
"Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx
At line:1 char:19
+ Set-SPUsageService <<<<  -LoggingEnabled 0 -UsageLogLocation F:\SharePoint Lo
gs1\ -UsageLogMaxSpaceGB 2
    + CategoryInfo          : InvalidArgument: (:) [Set-SPUsageService], Param
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.SharePo

when I tried the same options from Central Admin, I could successfully set those settings. After doing some research I found that when we configure these settings through PowerShell it doesn’t take the space in logs location path. So I tried again without space in path, it executed successfully J

Set-SPUsageService -LoggingEnabled 1 -UsageLogLocation F:\SharePointLogs                                   -UsageLogMaxSpaceGB 2
Or if I specify the path in either quotation mark (‘’) or in double quotes (“”) then it works successfully as follows

Set-SPUsageService -LoggingEnabled 1 -UsageLogLocation ‘F:\SharePoint Logs’                                          -UsageLogMaxSpaceGB 2

Set-SPUsageService -LoggingEnabled 1 -UsageLogLocation “F:\SharePoint Logs”                                        -UsageLogMaxSpaceGB 2

Here, I just want to share the error which occurs since this error message is different that whot should be it. 

Happy ReadingsJ