December 18, 2011 at 10:56 pm
Comments posted to this topic are about the item Automating Daily Checks with Powershell
December 19, 2011 at 2:43 am
I've set this up as I'm looking to create a full-on daily server checks checks myself, so this was very timely.
I'm getting an error though:
You must provide a value expression on the right-hand side of the '-' operator.
At C:\SQLChecks\htmlreports.ps1:427 char:18
+ "Backup Status" - <<<< Head $a -Body "<H2> ERRORSLIST </H2>"|out-file $workingdir\errors.html
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : ExpectedValueExpression
The line at the location is:
"Backup Status" -Head $a -Body "<H2> ERRORSLIST </H2>"|out-file $workingdir\errors.html
As I don't know anything about the inner working of PowerShell yet, Help?
DBA (Dogsbody with Bad Attitude)
December 19, 2011 at 2:49 am
Ahh, never mind. We're on SQL 2005 so this won't work anyway.
Back to roll-my-own, then...
DBA (Dogsbody with Bad Attitude)
December 19, 2011 at 3:37 am
You could add the date parameters into the Xp_readerrorlog stmt if you wish to limit the initial result set?
SQL DBA
Every day is a school day, and don't trust anyone who tells you any different.
http://sqlblogness.blogspot.co.uk
December 19, 2011 at 5:33 am
Hi,
I am also struggling with the same issue that was mentioned above, when I try execute the powershell script, on the line:
"Backup Status" -Head $a -Body "<H2> ERRORSLIST </H2>"|out-file $workingdir\errors.html
The error message is:
You must provide a value expression on the right-hand side of the '-' operator.
At C:\Data\Powershell\HTMLReports\working\htmlreports.ps1:427 char:18
+ "Backup Status" - <<<< Head $a -Body "<H2> ERRORSLIST </H2>"|out-file $workingdir\errors.html
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedValueExpression
I dont have much experience with Powershell so Im not sure what the problem is,
does anyone know what the problem could be?
Forgive me if I am missing something silly,
Thanks
Richard
December 19, 2011 at 5:49 am
richard.bothma (12/19/2011)
Hi,I am also struggling with the same issue that was mentioned above, when I try execute the powershell script, on the line:
"Backup Status" -Head $a -Body "<H2> ERRORSLIST </H2>"|out-file $workingdir\errors.html
The error message is:
You must provide a value expression on the right-hand side of the '-' operator.
At C:\Data\Powershell\HTMLReports\working\htmlreports.ps1:427 char:18
+ "Backup Status" - <<<< Head $a -Body "<H2> ERRORSLIST </H2>"|out-file $workingdir\errors.html
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedValueExpression
I dont have much experience with Powershell so Im not sure what the problem is,
does anyone know what the problem could be?
Forgive me if I am missing something silly,
Thanks
Richard
Not sure why uou are getting that error- and not in front of a machine right now so i cant try to reproduce, but that line is just a header row. I think you should be able to just comment it out.
December 19, 2011 at 5:58 am
NJ-DBA (12/19/2011)
richard.bothma (12/19/2011)
Hi,I am also struggling with the same issue that was mentioned above, when I try execute the powershell script, on the line:
"Backup Status" -Head $a -Body "<H2> ERRORSLIST </H2>"|out-file $workingdir\errors.html
The error message is:
You must provide a value expression on the right-hand side of the '-' operator.
At C:\Data\Powershell\HTMLReports\working\htmlreports.ps1:427 char:18
+ "Backup Status" - <<<< Head $a -Body "<H2> ERRORSLIST </H2>"|out-file $workingdir\errors.html
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedValueExpression
I dont have much experience with Powershell so Im not sure what the problem is,
does anyone know what the problem could be?
Forgive me if I am missing something silly,
Thanks
Richard
Not sure why uou are getting that error- and not in front of a machine right now so i cant try to reproduce, but that line is just a header row. I think you should be able to just comment it out.
After a second look, there should not be a <<< in the code. Look at the script again. Is this an artifact of your copy/paste? The code should just have -head ... Remove those symbols and any space... Sorry typing from my phone
December 19, 2011 at 6:28 am
No, the <<< is inserted by the PowerShell parser to show where the error is in the line.
Personally, I think that just stating line number is enough to find an error.
DBA (Dogsbody with Bad Attitude)
December 19, 2011 at 6:54 am
I too have to prove that I have checked the servers each day. I also have to include any errors in the sql server error log for the past 24 hours. In addition to the sql server error log, I also have to include any errors from the windows event logs for the last 24 hours. Using Powershell has greatly simplified my life and all it took was an investment in learning some things about Powershell.
Powershell is a great tools for producing html reports and sending these reports out in email.
December 19, 2011 at 7:25 am
HooO! any chance of a copy of your script? We're on 2005, so no sql built-ins are available for our PowerShell.
Does your script work on 2005 ?
DBA (Dogsbody with Bad Attitude)
December 19, 2011 at 7:28 am
I can post the scripts once I replace items that are specific to my company.
December 19, 2011 at 7:29 am
Excellent, many thanks.
DBA (Dogsbody with Bad Attitude)
December 19, 2011 at 8:20 am
Attached is a zip file with the scripts that I use.
December 19, 2011 at 9:23 am
Cheers for this.. I'll be working on this over the next few days..this will be a great help
DBA (Dogsbody with Bad Attitude)
December 19, 2011 at 10:09 am
Barry G Freeman (12/19/2011)
I've set this up as I'm looking to create a full-on daily server checks checks myself, so this was very timely.I'm getting an error though:
You must provide a value expression on the right-hand side of the '-' operator.
At C:\SQLChecks\htmlreports.ps1:427 char:18
+ "Backup Status" - <<<< Head $a -Body "<H2> ERRORSLIST </H2>"|out-file $workingdir\errors.html
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : ExpectedValueExpression
The line at the location is:
"Backup Status" -Head $a -Body "<H2> ERRORSLIST </H2>"|out-file $workingdir\errors.html
As I don't know anything about the inner working of PowerShell yet, Help?
Hi Barry, I got the same error message as you. I had a look at the code on the lines above and there seems to be a pattern similar to 2 of the lines (411 and 415 respectively). I added the following line to the beginning of line 427 that seemed to get the PowerShell script running at least
"$results7 |convertto-html -Title "
I'm a noob to PowerShell too, so hope that works for you.
Wolraad
Viewing 15 posts - 1 through 15 (of 47 total)
You must be logged in to reply to this topic. Login to reply