SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Automating Daily Checks with Powershell


Automating Daily Checks with Powershell

Author
Message
NJ-DBA
NJ-DBA
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2263 Visits: 1546
Comments posted to this topic are about the item Automating Daily Checks with Powershell
Barry G Freeman
Barry G Freeman
SSC-Enthusiastic
SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)

Group: General Forum Members
Points: 143 Visits: 286
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: (Smile [], 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)
Barry G Freeman
Barry G Freeman
SSC-Enthusiastic
SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)

Group: General Forum Members
Points: 143 Visits: 286
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)
Ness
Ness
Mr or Mrs. 500
Mr or Mrs. 500 (599 reputation)Mr or Mrs. 500 (599 reputation)Mr or Mrs. 500 (599 reputation)Mr or Mrs. 500 (599 reputation)Mr or Mrs. 500 (599 reputation)Mr or Mrs. 500 (599 reputation)Mr or Mrs. 500 (599 reputation)Mr or Mrs. 500 (599 reputation)

Group: General Forum Members
Points: 599 Visits: 974
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
richard.bothma
richard.bothma
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 26
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: (Smile [], 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
NJ-DBA
NJ-DBA
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2263 Visits: 1546
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: (Smile [], 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.
NJ-DBA
NJ-DBA
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2263 Visits: 1546
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: (Smile [], 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
Barry G Freeman
Barry G Freeman
SSC-Enthusiastic
SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)

Group: General Forum Members
Points: 143 Visits: 286
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)
skron
skron
SSC Veteran
SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)

Group: General Forum Members
Points: 261 Visits: 56
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.
Barry G Freeman
Barry G Freeman
SSC-Enthusiastic
SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)

Group: General Forum Members
Points: 143 Visits: 286
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)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search