{"id":180,"date":"2015-11-20T09:27:59","date_gmt":"2015-11-20T15:27:59","guid":{"rendered":"http:\/\/www.sqlnuggets.com\/?p=180"},"modified":"2017-03-31T15:16:44","modified_gmt":"2017-03-31T20:16:44","slug":"call-multiple-sql-jobs-in-sequence-via-powershell","status":"publish","type":"post","link":"https:\/\/sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/","title":{"rendered":"Call Multiple SQL Jobs In Sequence Via PowerShell"},"content":{"rendered":"<p>Recently I had an issue come up where I needed to run about 15 SQL Agent Jobs in a specific order, bouncing back and forth across multiple SQL Servers, ensuring that each job completed successfully before starting the next job in the series.\u00a0 On top of that, I was going to have to perform this action multiple times a day, randomly, for several days.\u00a0 After doing this manually a couple of times, I realized that I would be much better off creating a PowerShell script to do this for me.<\/p>\n<p>To lay out the scenario of what I was trying to accomplish, I had 15 jobs spread across 3 SQL Servers that needed to be called as follows:<\/p>\n<ul>\n<li>Server 1 &#8211; Job 1, Job 2, Job 3, Job 4, Job 5<\/li>\n<li>Server 2 &#8211; Job 6<\/li>\n<li>Server 1 &#8211; Job 7, Job 8<\/li>\n<li>Server 3 &#8211; Job 9, Job 10<\/li>\n<li>Server 1 &#8211; Job 11, Job 12, Job 13, Job 14, Job 15<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>To accomplish this, I wrote the following quick and dirty PowerShell script.\u00a0 The script allows you to pass in a server name and an array of job names, and it will connect to the specified SQL server and run the jobs in the order they are listed, waiting for each job to complete successfully before starting the next job.\u00a0 In the event a job fails (or completes with any status other than &#8220;succeeded&#8221;), the script will stop processing and not run any further jobs.<\/p>\n<pre class=\"theme:powershell-ise striped:false lang:ps decode:true\">Import-Module SQLPS -DisableNameChecking\r\n\r\n# create a function that takes a SQL Server name and array of SQL Jobs to be run on that server\r\nfunction invoke-sqljobs([string]$ServerName, [array]$JobList)\r\n{   \r\n    # Load SMO and instantiate the server object\r\n    [System.Reflection.Assembly]::LoadWithPartialName(\"Microsoft.SqlServer.Smo\") |Out-Null;\r\n    [Microsoft.SqlServer.Management.Smo.Server]$sqlServer = New-Object Microsoft.SqlServer.Management.Smo.Server $ServerName;\r\n\r\n    #loop through the list of jobs\r\n    foreach($i in $JobList)\r\n        {\r\n\t    #get the specified job\r\n\t    [Microsoft.SqlServer.Management.Smo.Agent.Job]$job = ($sqlServer.JobServer.Jobs | ? { $_.Name -eq $i });\r\n            \r\n            $job.Start();\r\n            $jobStartTime = Get-Date\r\n\r\n            #wait a second to give the job time to get started; otherwise PowerShell will check the job status before it has chanaged\r\n            Start-Sleep -s 1\r\n\r\n            Write-Host \"$Job Started: $jobStartTime\"\r\n            $jobStatus = $job.CurrentRunStatus\r\n\t\t\r\n\t    #start a loop that keeps refreshing and checking the job status until it becomes \"idle\"; once the satus becomes \"idle\" the job has completed\r\n\t    #this ensures that each job completes before the next job is started.\r\n            while($jobStatus -ne 'Idle')\r\n            {       \r\n                $job.Refresh() #refresh the job connection\r\n                $jobStatus = $job.CurrentRunStatus #check the job's status\r\n            }\r\n\r\n\t    $jobEndTime = Get-Date\r\n\t    #check to see if the job succeeded\r\n            $jobResult = $job.LastRunOutcome \r\n\t\t\t\r\n            Write-Host \"$Job Completed with a Status of $jobResult : $jobEndTime\" \r\n\r\n            #if the result is not \"Succeeded\" break out of the loop and do not process any more jobs\r\n            if ($jobResult -ne 'Succeeded') {break}\r\n    }\r\n}\r\n\r\n#call the jobs on each server, creating the JobList in the order the jobs need to run.\r\ninvoke-sqljobs -ServerName 'Server1' -JobList @('Job 1','Job 2','Job 3','Job 4','Job 5')\r\ninvoke-sqljobs -ServerName 'Server2' -JobList @('Job 6')\r\ninvoke-sqljobs -ServerName 'Server1' -JobList @('Job 7','Job 8')\r\ninvoke-sqljobs -ServerName 'Server3' -JobList @('Job 9','Job 10')\r\ninvoke-sqljobs -ServerName 'Server1' -JobList @('Job 11','Job 12','Job 13','Job 14','Job 15')<\/pre>\n<p>This script can probably be refined a little bit, with some error handling thrown in, but it is only being used temporarily and does what I need so I&#8217;m happy with it.\u00a0 I&#8217;m just running it locally from within my IDE so I just pull it up, click &#8220;go&#8221;, and come back in a half hour to check on it.\u00a0 Now there&#8217;s no need to have to call each job manually and wait for it to complete!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I had an issue come up where I needed to run about 15 SQL Agent Jobs in a specific order, bouncing back and forth across multiple SQL Servers, ensuring &#8230;<\/p>\n","protected":false},"author":2,"featured_media":352,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[20],"tags":[21],"class_list":["post-180","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-automation"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Call Multiple SQL Jobs In Sequence Via PowerShell - SQL Nuggets<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Call Multiple SQL Jobs In Sequence Via PowerShell - SQL Nuggets\" \/>\n<meta property=\"og:description\" content=\"Recently I had an issue come up where I needed to run about 15 SQL Agent Jobs in a specific order, bouncing back and forth across multiple SQL Servers, ensuring ...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Nuggets\" \/>\n<meta property=\"article:published_time\" content=\"2015-11-20T15:27:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-03-31T20:16:44+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.sqlnuggets.com\/wp-content\/uploads\/2017\/03\/powershell-logo-e1490835665309.png\" \/>\n\t<meta property=\"og:image:width\" content=\"235\" \/>\n\t<meta property=\"og:image:height\" content=\"123\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Eric Cobb\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cfgears\" \/>\n<meta name=\"twitter:site\" content=\"@sqlnugg\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Eric Cobb\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/call-multiple-sql-jobs-in-sequence-via-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/call-multiple-sql-jobs-in-sequence-via-powershell\\\/\"},\"author\":{\"name\":\"Eric Cobb\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#\\\/schema\\\/person\\\/210536254addbc1b9d2d95dc1448b38a\"},\"headline\":\"Call Multiple SQL Jobs In Sequence Via PowerShell\",\"datePublished\":\"2015-11-20T15:27:59+00:00\",\"dateModified\":\"2017-03-31T20:16:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/call-multiple-sql-jobs-in-sequence-via-powershell\\\/\"},\"wordCount\":311,\"commentCount\":1,\"publisher\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#organization\"},\"image\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/call-multiple-sql-jobs-in-sequence-via-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2017\\\/03\\\/powershell-logo-e1490835665309.png\",\"keywords\":[\"Automation\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\\\/\\\/www.sqlnuggets.com\\\/call-multiple-sql-jobs-in-sequence-via-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/call-multiple-sql-jobs-in-sequence-via-powershell\\\/\",\"url\":\"http:\\\/\\\/www.sqlnuggets.com\\\/call-multiple-sql-jobs-in-sequence-via-powershell\\\/\",\"name\":\"Call Multiple SQL Jobs In Sequence Via PowerShell - SQL Nuggets\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/call-multiple-sql-jobs-in-sequence-via-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/call-multiple-sql-jobs-in-sequence-via-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2017\\\/03\\\/powershell-logo-e1490835665309.png\",\"datePublished\":\"2015-11-20T15:27:59+00:00\",\"dateModified\":\"2017-03-31T20:16:44+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/call-multiple-sql-jobs-in-sequence-via-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/www.sqlnuggets.com\\\/call-multiple-sql-jobs-in-sequence-via-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/call-multiple-sql-jobs-in-sequence-via-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2017\\\/03\\\/powershell-logo-e1490835665309.png\",\"contentUrl\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2017\\\/03\\\/powershell-logo-e1490835665309.png\",\"width\":235,\"height\":123},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/call-multiple-sql-jobs-in-sequence-via-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\\\/\\\/www.sqlnuggets.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Call Multiple SQL Jobs In Sequence Via PowerShell\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#website\",\"url\":\"http:\\\/\\\/www.sqlnuggets.com\\\/\",\"name\":\"SQL Nuggets\",\"description\":\"Nuggets Of SQL Server Knowledge\",\"publisher\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\\\/\\\/www.sqlnuggets.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#organization\",\"name\":\"SQL Nuggets\",\"url\":\"http:\\\/\\\/www.sqlnuggets.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2023\\\/11\\\/website-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2023\\\/11\\\/website-logo.jpg\",\"width\":320,\"height\":54,\"caption\":\"SQL Nuggets\"},\"image\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/sqlnugg\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/ericcobb\\\/\"]},{\"@type\":\"Person\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#\\\/schema\\\/person\\\/210536254addbc1b9d2d95dc1448b38a\",\"name\":\"Eric Cobb\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ca1fc0c7054a668e048f09d412cd4ebf89833c4630fbbfccca78a0678a6bdc2?s=96&d=mm&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ca1fc0c7054a668e048f09d412cd4ebf89833c4630fbbfccca78a0678a6bdc2?s=96&d=mm&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ca1fc0c7054a668e048f09d412cd4ebf89833c4630fbbfccca78a0678a6bdc2?s=96&d=mm&r=pg\",\"caption\":\"Eric Cobb\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/cfgears\"],\"url\":\"https:\\\/\\\/sqlnuggets.com\\\/author\\\/eric-cobb\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Call Multiple SQL Jobs In Sequence Via PowerShell - SQL Nuggets","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Call Multiple SQL Jobs In Sequence Via PowerShell - SQL Nuggets","og_description":"Recently I had an issue come up where I needed to run about 15 SQL Agent Jobs in a specific order, bouncing back and forth across multiple SQL Servers, ensuring ...","og_url":"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/","og_site_name":"SQL Nuggets","article_published_time":"2015-11-20T15:27:59+00:00","article_modified_time":"2017-03-31T20:16:44+00:00","og_image":[{"width":235,"height":123,"url":"http:\/\/www.sqlnuggets.com\/wp-content\/uploads\/2017\/03\/powershell-logo-e1490835665309.png","type":"image\/png"}],"author":"Eric Cobb","twitter_card":"summary_large_image","twitter_creator":"@cfgears","twitter_site":"@sqlnugg","twitter_misc":{"Written by":"Eric Cobb","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/#article","isPartOf":{"@id":"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/"},"author":{"name":"Eric Cobb","@id":"http:\/\/www.sqlnuggets.com\/#\/schema\/person\/210536254addbc1b9d2d95dc1448b38a"},"headline":"Call Multiple SQL Jobs In Sequence Via PowerShell","datePublished":"2015-11-20T15:27:59+00:00","dateModified":"2017-03-31T20:16:44+00:00","mainEntityOfPage":{"@id":"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/"},"wordCount":311,"commentCount":1,"publisher":{"@id":"http:\/\/www.sqlnuggets.com\/#organization"},"image":{"@id":"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/03\/powershell-logo-e1490835665309.png","keywords":["Automation"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/","url":"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/","name":"Call Multiple SQL Jobs In Sequence Via PowerShell - SQL Nuggets","isPartOf":{"@id":"http:\/\/www.sqlnuggets.com\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/#primaryimage"},"image":{"@id":"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/03\/powershell-logo-e1490835665309.png","datePublished":"2015-11-20T15:27:59+00:00","dateModified":"2017-03-31T20:16:44+00:00","breadcrumb":{"@id":"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/#primaryimage","url":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/03\/powershell-logo-e1490835665309.png","contentUrl":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/03\/powershell-logo-e1490835665309.png","width":235,"height":123},{"@type":"BreadcrumbList","@id":"http:\/\/www.sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.sqlnuggets.com\/"},{"@type":"ListItem","position":2,"name":"Call Multiple SQL Jobs In Sequence Via PowerShell"}]},{"@type":"WebSite","@id":"http:\/\/www.sqlnuggets.com\/#website","url":"http:\/\/www.sqlnuggets.com\/","name":"SQL Nuggets","description":"Nuggets Of SQL Server Knowledge","publisher":{"@id":"http:\/\/www.sqlnuggets.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.sqlnuggets.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/www.sqlnuggets.com\/#organization","name":"SQL Nuggets","url":"http:\/\/www.sqlnuggets.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.sqlnuggets.com\/#\/schema\/logo\/image\/","url":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2023\/11\/website-logo.jpg","contentUrl":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2023\/11\/website-logo.jpg","width":320,"height":54,"caption":"SQL Nuggets"},"image":{"@id":"http:\/\/www.sqlnuggets.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/sqlnugg","https:\/\/www.linkedin.com\/in\/ericcobb\/"]},{"@type":"Person","@id":"http:\/\/www.sqlnuggets.com\/#\/schema\/person\/210536254addbc1b9d2d95dc1448b38a","name":"Eric Cobb","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3ca1fc0c7054a668e048f09d412cd4ebf89833c4630fbbfccca78a0678a6bdc2?s=96&d=mm&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/3ca1fc0c7054a668e048f09d412cd4ebf89833c4630fbbfccca78a0678a6bdc2?s=96&d=mm&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3ca1fc0c7054a668e048f09d412cd4ebf89833c4630fbbfccca78a0678a6bdc2?s=96&d=mm&r=pg","caption":"Eric Cobb"},"sameAs":["https:\/\/x.com\/cfgears"],"url":"https:\/\/sqlnuggets.com\/author\/eric-cobb\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/03\/powershell-logo-e1490835665309.png","jetpack_shortlink":"https:\/\/wp.me\/pdyDvE-2U","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":341,"url":"https:\/\/sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/","url_meta":{"origin":180,"position":0},"title":"Calling PowerShell From SQL Agent Gives Syntax Error","author":"Eric Cobb","date":"March 16, 2017","format":false,"excerpt":"One cool thing that you can do in\u00a0SQL Server that a lot of people don't know about is\u00a0run PowerShell code\u00a0from a SQL Agent job. \u00a0However, I recently ran into a problem when trying to schedule a SQL Agent job to run a PowerShell script. \u00a0The script is fairly simple, it\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/sqlnuggets.com\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1307,"url":"https:\/\/sqlnuggets.com\/disable-telemetry-on-multiple-sql-servers-with-powershell\/","url_meta":{"origin":180,"position":1},"title":"Disable Telemetry On Multiple SQL Servers With PowerShell","author":"Eric Cobb","date":"February 18, 2020","format":false,"excerpt":"Starting with SQL Server 2016, when you install SQL Server it also installs the CEIP (Customer Experience Improvement Program) Services, also known at Telemetry. In previous versions of SQL Server this was optional, but as of SQL Server 2016 it is automatically installed and enabled by default. Now whether this\u2026","rel":"","context":"In &quot;Configurations&quot;","block_context":{"text":"Configurations","link":"https:\/\/sqlnuggets.com\/category\/configurations\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/02\/binoculars-431488_1280.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/02\/binoculars-431488_1280.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/02\/binoculars-431488_1280.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/02\/binoculars-431488_1280.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/02\/binoculars-431488_1280.jpg?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":887,"url":"https:\/\/sqlnuggets.com\/using-dbatools-powershell-module-to-configure-sql-server\/","url_meta":{"origin":180,"position":2},"title":"Using dbatools PowerShell Module To Configure SQL Server","author":"Eric Cobb","date":"October 9, 2018","format":false,"excerpt":"The more I use\u00a0the\u00a0dbatools PowerShell module, the more I like it.\u00a0 It really is a solid set of scripts that allow you to easily manage your SQL Servers via PowerShell.\u00a0 If you are not familiar with dbatools, I recommend you head over to my previous post,\u00a0Getting Started With The dbatools\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/sqlnuggets.com\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/07\/powershell4.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/07\/powershell4.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/07\/powershell4.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":870,"url":"https:\/\/sqlnuggets.com\/getting-started-with-the-dbatools-powershell-module\/","url_meta":{"origin":180,"position":3},"title":"Getting Started With The dbatools PowerShell Module","author":"Eric Cobb","date":"September 20, 2018","format":false,"excerpt":"If you are looking for a super easy way to start using PowerShell to manage your SQL Servers, then the\u00a0dbatools PowerShell module is for you!\u00a0 For those that aren't familiar, dbatools is a\u00a0free\u00a0PowerShell module with over 400 SQL Server best practice, administration, development and migration commands included. I have to\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/sqlnuggets.com\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/07\/powershell4.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/07\/powershell4.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/07\/powershell4.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":1350,"url":"https:\/\/sqlnuggets.com\/setting-up-database-mail-and-sql-agent-alerts-with-powershell\/","url_meta":{"origin":180,"position":4},"title":"Setting Up Database Mail And SQL Agent Alerts With PowerShell","author":"Eric Cobb","date":"April 21, 2020","format":false,"excerpt":"As a DBA, you need to know when there's a problem on your SQL Servers. And while I highly recommend you use a full-fledged monitoring system, there are also some things you can set up on your SQL Servers so that they will tell you when certain things go wrong.\u2026","rel":"","context":"In &quot;Configurations&quot;","block_context":{"text":"Configurations","link":"https:\/\/sqlnuggets.com\/category\/configurations\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/04\/banner-1165979_1280.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/04\/banner-1165979_1280.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/04\/banner-1165979_1280.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/04\/banner-1165979_1280.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/04\/banner-1165979_1280.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":1049,"url":"https:\/\/sqlnuggets.com\/patching-multiple-sql-servers-with-powershell-and-dbatools\/","url_meta":{"origin":180,"position":5},"title":"Patching Multiple SQL Servers With Powershell and dbatools","author":"Eric Cobb","date":"July 18, 2019","format":false,"excerpt":"Patching SQL Server can sometimes be a time consuming process, especially when you have multiple servers that need to be patched. Remoting in to each box to run through the update wizard is tedious, and if you have multiple patches to apply you're going to be spending a considerable chunk\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/sqlnuggets.com\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/07\/powershell4.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/07\/powershell4.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2018\/07\/powershell4.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/posts\/180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/comments?post=180"}],"version-history":[{"count":0,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/posts\/180\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/media\/352"}],"wp:attachment":[{"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/media?parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/categories?post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/tags?post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}