Jump to content

Recommended Posts

Posted

I am trying to get commandreporter to run, exporting a file. This is the report:

 

report.png

 

And this is my Powershell script to run commandreporter:

 

$today = (Get-Date).ToString('yyyy-MM-dd')
$var = 'StatusListStatus NULL1NULLFurther Intervention Required1Further Intervention RequiredResolved1ResolvedResolved(1)1Resolved(1)Unresolved1UnresolvedUnresolved(1)1Unresolved(1)DateDateRangeDate is between' + $today + 'T00:00:00' + $today + 'T23:59:59'
$params = '/PARAMS:' + $var
& "c:\program files (x86)\SIMS\SIMS .Net\CommandReporter.exe" "/USER:USER" "/PASSWORD:PWORD" "/REPORT:Behaviour report listing April 08 - Auto" $params '/OUTPUT:"report.csv"'

 

There's more code after that, doing stuff with the output file, but not needed here.

 

My issue is this - it is ignoring my date entries. I have confirmed that the string is actually generating with the right date, but the output file has used the dates that were in the fields when the report was created.

 

What am I doing wrong here? I've tried doing it by exporting the params to a file instead, but that does the same thing.

Posted

Commandreporter is quite fussy with syntax. A little (working) CMD we have is formatted like:

 

"C:\Program Files (x86)\SIMS\SIMS .net\CommandReporter.exe" /USER:xxxx /PASSWORD:xxxxx /SERVERNAME:server\simsxx /DATABASENAME:sims /REPORT:"reportname" /PARAMS:"StatusDateDate %yyyy%-%mm%-%dd%T01:00:00?" /OUTPUT:"D:\report.xml"

 

Worth checking the syntax of yours against this, I doubt there are differences in PS but it's possible.

  • Thanks 1
Posted (edited)
it is ignoring my date entries.

Try this...

 

$today = (Get-Date).ToString('yyyy-MM-dd')
$var = '


	Status
	List
	Status 
	
		
			NULL
			1
			NULL
		
		
			Further Intervention Required
			1
			Further Intervention Required
		
		
			Resolved
			1
			Resolved
		
		
			Resolved(1)
			1
			Resolved(1)
		
		
			Unresolved
			1
			Unresolved
		
		
			Unresolved(1)
			1
			Unresolved(1)
		
	


	Date
	DateRange
	Date is between
	
		
			TODAYT00:00:00
			TODAYT23:59:59
		
	

' -replace 'TODAY',"$today" -replace "`t|`n",''

Start-Process -FilePath "${env:ProgramFiles(x86)}\SIMS\SIMS .Net\CommandReporter.exe" -ArgumentList '/USER:xxxxx','/PASSWORD:xxxxx','/SERVERNAME:Server\SIMS','/DATABASENAME:Sims','/REPORT:"Behaviour report listing April 08 - Auto"',"/PARAMS:$var",'/OUTPUT:"D:\Report.csv"'

 

If it works then it's probably caused by a quoting issue either by using backslashes to escape the double quotes or how the $today variables were inserted into the DateRange.

 

The reason I used the -replace operators was because it makes the easier to read (prior to the text being minified) and inserting the $today variables easier. :)

 

Note. Make sure the tabs used for indentation in $var don't get replaced by spaces if copying and pasting the script into a text editor.

Edited by Arthur

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...