Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Stairway to SQL Server Agent - Level 8: Using External programs with SQL Server Agent Expand / Collapse
Author
Message
Posted Saturday, October 15, 2011 3:07 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, May 30, 2014 11:41 AM
Points: 11, Visits: 62
Comments posted to this topic are about the item Stairway to SQL Server Agent - Level 8: Using External programs with SQL Server Agent


Post #1190969
Posted Thursday, December 29, 2011 7:25 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, November 6, 2014 8:22 AM
Points: 5, Visits: 114
Hi Richard,

I'm new with PowerShell. I'm doing some test and I have a question about the step 2 of this job. Where is the output of the PowerShell script?

Best regards and happy new year!

MARIO
Post #1227778
Posted Tuesday, January 3, 2012 9:19 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 1:06 PM
Points: 48, Visits: 267
Agree and disagree:

"repetitive tasks, or as in the case of CmdExec, any task that leaves the SQL Server environment is much simpler from the PowerShell subsystem.

Disagree:
Any repetitive SQL Server task can be easily done using t-sql inside SQL Server - that's what you have SQL Server Agent for!

Agree:
Tasks that leave the SQL Server environment - here PowerShell might be worth exploring.
Post #1229350
Posted Tuesday, January 3, 2012 10:05 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, May 30, 2014 11:41 AM
Points: 11, Visits: 62
By default the output in SQL Server Agent goes to the msdb.dbo.sysjobhistory table (that's what you see when you ask to view history from the job).

To get the output somewhere else, there are a number of possibilities, for example you could do this:

$server = new-object( 'Microsoft.SqlServer.Management.Smo.Server' ) “(local)”

foreach ($database in $server.databases)
{
$dbName = $database.Name
Write-Output "Database: $dbName" | Out-File c:\temp\temp.txt -append
}

Which will create and then append results to teh file c:\temp\temp.txt with the list of database names.



Post #1229406
Posted Tuesday, January 3, 2012 10:07 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, November 6, 2014 8:22 AM
Points: 5, Visits: 114
Thanks Richar. I'll try it.
Post #1229409
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse