Connect to SQL server using powershell

Hello, I'm just trying to connect to the SQL server using powersehll and check the job status of all the jobs in that server.

The server I'm trying to connect to is a local host and instance is MSSQLSERVER(Localhost\MSSQLSERVER)

Here's the code that I'm using

[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null
$sql = New-Object ('Microsoft.SqlServer.Management.Smo.Server') ".\MSSQLSERVER"
$sql| Get-Member -name *job*
$sql.JobServer


As far as I know, this should give me a list of all the job exists in that instance. But the script simply  executes but would not shown an output on the screen, except for this 

$sql| Get-Member -name *job*

which simply lists all the members of the object 'sql.' Further, I've verified that the server agent is running and also a job is running currently.

Any inputs here ?

Thank

August 26th, 2015 2:30pm

Post in SQLServer developer forum to learn how to use SMO to manage the agent.

Free Windows Admin Tool Kit Click here and download it now
August 26th, 2015 4:18pm

Will do that. Thanks !
August 27th, 2015 1:08am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics