{"id":341,"date":"2017-03-16T10:27:36","date_gmt":"2017-03-16T15:27:36","guid":{"rendered":"http:\/\/www.sqlnuggets.com\/?p=341"},"modified":"2017-03-29T08:51:09","modified_gmt":"2017-03-29T13:51:09","slug":"calling-powershell-from-sql-agent-gives-syntax-error","status":"publish","type":"post","link":"https:\/\/sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/","title":{"rendered":"Calling PowerShell From SQL Agent Gives Syntax Error"},"content":{"rendered":"<p>One cool thing that you can do in\u00a0SQL Server that a lot of people don&#8217;t know about is\u00a0<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/hh213688.aspx\" target=\"_blank\">run PowerShell code\u00a0from a SQL Agent job<\/a>. \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 scans a local directory and removes any backup files over 7 days old.<\/p>\n<pre class=\"theme:powershell-ise striped:false lang:ps decode:true\">$BackupDir = 'C:\\MSSQL\\Backup\\Path'\r\n$RetentionInDays = '7'\r\n\r\nGet-ChildItem -Path $BackupDir -filter '*.bak' -Recurse -force | `\r\n? {$_.lastwritetime -lt (Get-Date).AddDays(- $($RetentionInDays)) -and -not ($_.psiscontainer)} | remove-item -force<\/pre>\n<p>The script runs with no problems in PowerShell ISE on the server, however when trying to run the above code from a SQL Agent job, I get the following error.<\/p>\n<h5><span style=\"color: #ff0000;\">Unable to start execution of step (reason: Syntax error). The step failed.<\/span><\/h5>\n<p>&nbsp;<\/p>\n<p>That&#8217;s not a very informative error. \u00a0 After quite a bit of digging, I came across this <a href=\"http:\/\/dba.stackexchange.com\/questions\/58669\/sql-agent-powershell-step-syntax-error\" target=\"_blank\">DBA\u00a0Stack Exchange<\/a> post that led me to the solution. \u00a0As it turns out, you cannot use a\u00a0PowerShell Sub-Expression Operator in a SQL Agent job, because SQL Sever sees the syntax of <em>$($VarName)<\/em> as a <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/ssms\/agent\/use-tokens-in-job-steps\" target=\"_blank\">User Token<\/a>. \u00a0So the fix for me was to remove the\u00a0<em>$($RetentionInDays)<\/em> variable and just hard code the value instead. \u00a0 Running the below code in my SQL Agent job executes without error.<\/p>\n<pre class=\"theme:powershell-ise striped:false lang:ps decode:true\">$BackupDir = 'C:\\MSSQL\\Backup\\Path'\r\n\r\nGet-ChildItem -Path $BackupDir -filter '*.bak' -Recurse -force | `\r\n? {$_.lastwritetime -lt (Get-Date).AddDays(-7) -and -not ($_.psiscontainer)} | remove-item -force<\/pre>\n<p>Since I was only using this syntax for one variable, it was an easy fix for me. \u00a0However, some people may have a lot of variables in their PowerShell script that they don&#8217;t want to hard code, which is understandable. \u00a0In that case, I would recommend saving the PowerShell code off to a .ps1 file, then executing that from the SQL Agent. \u00a0The above linked Stack Exchange post also\u00a0shows how you can reset your variables so you don&#8217;t have to use the problematic syntax in your SQL Agent job.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One cool thing that you can do in\u00a0SQL Server that a lot of people don&#8217;t know about is\u00a0run PowerShell code\u00a0from a SQL Agent job. \u00a0However, I recently ran into a &#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":false,"_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":[47],"class_list":["post-341","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-sql-agent"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Calling PowerShell From SQL Agent Gives Syntax Error - 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\/calling-powershell-from-sql-agent-gives-syntax-error\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Calling PowerShell From SQL Agent Gives Syntax Error - SQL Nuggets\" \/>\n<meta property=\"og:description\" content=\"One cool thing that you can do in\u00a0SQL Server that a lot of people don&#8217;t know about is\u00a0run PowerShell code\u00a0from a SQL Agent job. \u00a0However, I recently ran into a ...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Nuggets\" \/>\n<meta property=\"article:published_time\" content=\"2017-03-16T15:27:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-03-29T13:51:09+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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/calling-powershell-from-sql-agent-gives-syntax-error\\\/#article\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/calling-powershell-from-sql-agent-gives-syntax-error\\\/\"},\"author\":{\"name\":\"Eric Cobb\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#\\\/schema\\\/person\\\/210536254addbc1b9d2d95dc1448b38a\"},\"headline\":\"Calling PowerShell From SQL Agent Gives Syntax Error\",\"datePublished\":\"2017-03-16T15:27:36+00:00\",\"dateModified\":\"2017-03-29T13:51:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/calling-powershell-from-sql-agent-gives-syntax-error\\\/\"},\"wordCount\":291,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#organization\"},\"image\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/calling-powershell-from-sql-agent-gives-syntax-error\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2017\\\/03\\\/powershell-logo-e1490835665309.png\",\"keywords\":[\"SQL Agent\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\\\/\\\/www.sqlnuggets.com\\\/calling-powershell-from-sql-agent-gives-syntax-error\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/calling-powershell-from-sql-agent-gives-syntax-error\\\/\",\"url\":\"http:\\\/\\\/www.sqlnuggets.com\\\/calling-powershell-from-sql-agent-gives-syntax-error\\\/\",\"name\":\"Calling PowerShell From SQL Agent Gives Syntax Error - SQL Nuggets\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/calling-powershell-from-sql-agent-gives-syntax-error\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/calling-powershell-from-sql-agent-gives-syntax-error\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2017\\\/03\\\/powershell-logo-e1490835665309.png\",\"datePublished\":\"2017-03-16T15:27:36+00:00\",\"dateModified\":\"2017-03-29T13:51:09+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/calling-powershell-from-sql-agent-gives-syntax-error\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/www.sqlnuggets.com\\\/calling-powershell-from-sql-agent-gives-syntax-error\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/calling-powershell-from-sql-agent-gives-syntax-error\\\/#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\\\/calling-powershell-from-sql-agent-gives-syntax-error\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\\\/\\\/www.sqlnuggets.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Calling PowerShell From SQL Agent Gives Syntax Error\"}]},{\"@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":"Calling PowerShell From SQL Agent Gives Syntax Error - 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\/calling-powershell-from-sql-agent-gives-syntax-error\/","og_locale":"en_US","og_type":"article","og_title":"Calling PowerShell From SQL Agent Gives Syntax Error - SQL Nuggets","og_description":"One cool thing that you can do in\u00a0SQL Server that a lot of people don&#8217;t know about is\u00a0run PowerShell code\u00a0from a SQL Agent job. \u00a0However, I recently ran into a ...","og_url":"http:\/\/www.sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/","og_site_name":"SQL Nuggets","article_published_time":"2017-03-16T15:27:36+00:00","article_modified_time":"2017-03-29T13:51:09+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":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/#article","isPartOf":{"@id":"http:\/\/www.sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/"},"author":{"name":"Eric Cobb","@id":"http:\/\/www.sqlnuggets.com\/#\/schema\/person\/210536254addbc1b9d2d95dc1448b38a"},"headline":"Calling PowerShell From SQL Agent Gives Syntax Error","datePublished":"2017-03-16T15:27:36+00:00","dateModified":"2017-03-29T13:51:09+00:00","mainEntityOfPage":{"@id":"http:\/\/www.sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/"},"wordCount":291,"commentCount":0,"publisher":{"@id":"http:\/\/www.sqlnuggets.com\/#organization"},"image":{"@id":"http:\/\/www.sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/03\/powershell-logo-e1490835665309.png","keywords":["SQL Agent"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/www.sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/www.sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/","url":"http:\/\/www.sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/","name":"Calling PowerShell From SQL Agent Gives Syntax Error - SQL Nuggets","isPartOf":{"@id":"http:\/\/www.sqlnuggets.com\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/#primaryimage"},"image":{"@id":"http:\/\/www.sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2017\/03\/powershell-logo-e1490835665309.png","datePublished":"2017-03-16T15:27:36+00:00","dateModified":"2017-03-29T13:51:09+00:00","breadcrumb":{"@id":"http:\/\/www.sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/#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\/calling-powershell-from-sql-agent-gives-syntax-error\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.sqlnuggets.com\/"},{"@type":"ListItem","position":2,"name":"Calling PowerShell From SQL Agent Gives Syntax Error"}]},{"@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-5v","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1350,"url":"https:\/\/sqlnuggets.com\/setting-up-database-mail-and-sql-agent-alerts-with-powershell\/","url_meta":{"origin":341,"position":0},"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":180,"url":"https:\/\/sqlnuggets.com\/call-multiple-sql-jobs-in-sequence-via-powershell\/","url_meta":{"origin":341,"position":1},"title":"Call Multiple SQL Jobs In Sequence Via PowerShell","author":"Eric Cobb","date":"November 20, 2015","format":false,"excerpt":"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\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":887,"url":"https:\/\/sqlnuggets.com\/using-dbatools-powershell-module-to-configure-sql-server\/","url_meta":{"origin":341,"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":1307,"url":"https:\/\/sqlnuggets.com\/disable-telemetry-on-multiple-sql-servers-with-powershell\/","url_meta":{"origin":341,"position":3},"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":870,"url":"https:\/\/sqlnuggets.com\/getting-started-with-the-dbatools-powershell-module\/","url_meta":{"origin":341,"position":4},"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":897,"url":"https:\/\/sqlnuggets.com\/using-dbatools-powershell-module-to-set-maxdop-and-max-memory\/","url_meta":{"origin":341,"position":5},"title":"Using dbatools PowerShell Module To Set MAXDOP And Max Memory","author":"Eric Cobb","date":"November 27, 2018","format":false,"excerpt":"As I continue my blog series on using\u00a0the\u00a0dbatools PowerShell module, today I want to discuss using it to set MAXDOP and Max Memory on your SQL Server.\u00a0 This builds directly off of my previous post on\u00a0Using dbatools PowerShell Module To Configure SQL Server, so if you haven't seen that one\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\/341","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=341"}],"version-history":[{"count":0,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/posts\/341\/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=341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/categories?post=341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/tags?post=341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}