The command Export-LogReportCsv is used to extract admin traces from the delivery Controllers.
If the requirement is to extract the logs via the command using a scheduled task, the powershell throws unauthorized exception thrown error when the scheduled task is run under SYSTEM user context.
Powershell command: Export-LogReportCsv -OutputFile 'C:\Program Files\new\test.csv'
Error: Citrix.XDPowerShell.Status.ExceptionThrown,Citrix.ConfigurationLogging.Sdk.Commands.ExportLogReportCsvCommand
If we run the command with AD user with local admin rights it will work. However, if the requirement is to run the command using scheduled task as a SYSTEM user, then the following steps should be followed:
Note: Please make a back-up of the database before performing the below actions.
1. Open SQL and execute the below commands on the Citrix Site Database:
INSERT INTO [name of your site].[DAS].[Administrators] (Sid, UserIdentityType, Enabled, BuiltIn, Name, CloudNameExpiryTime, IsCloudGroup, IsHidden) VALUES ('S-1-5-18', '0', 'True', 'False', 'S-1-5-18', NULL, Null, 'False');
2. Open studio and validate under the Administrators tab. See screenshot for reference of how it should be displayed after running the command.
3. Edit the administrator and add Scope as All and Role as Full Administrator.
4. Once full admin permission has been updated then run the command as System permission and it should run successfully with report from delivery controller
We need to change the permission in the database to export the logs with system permission