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
SSCertifiable
SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)

Group: General Forum Members
Points: 7277 Visits: 1652
Comments posted to this topic are about the item Automating Daily Checks with Powershell
Barry G Freeman
Barry G Freeman
Old Hand
Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)

Group: General Forum Members
Points: 345 Visits: 312
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
Old Hand
Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)

Group: General Forum Members
Points: 345 Visits: 312
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
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2246 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
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 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
SSCertifiable
SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)

Group: General Forum Members
Points: 7277 Visits: 1652
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
SSCertifiable
SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)

Group: General Forum Members
Points: 7277 Visits: 1652
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
Old Hand
Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)

Group: General Forum Members
Points: 345 Visits: 312
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
Old Hand
Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)

Group: General Forum Members
Points: 307 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
Old Hand
Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)Old Hand (345 reputation)

Group: General Forum Members
Points: 345 Visits: 312
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