|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, April 03, 2013 12:29 PM
Points: 11,
Visits: 52
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 12:58 PM
Points: 5,
Visits: 68
|
|
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
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, May 24, 2013 1:32 AM
Points: 48,
Visits: 258
|
|
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.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, April 03, 2013 12:29 PM
Points: 11,
Visits: 52
|
|
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.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 12:58 PM
Points: 5,
Visits: 68
|
|
| Thanks Richar. I'll try it.
|
|
|
|