{"id":1604,"date":"2021-04-15T11:20:00","date_gmt":"2021-04-15T16:20:00","guid":{"rendered":"http:\/\/www.sqlnuggets.com\/?p=1604"},"modified":"2021-04-20T08:31:50","modified_gmt":"2021-04-20T13:31:50","slug":"powershell-compare-users-ad-groups","status":"publish","type":"post","link":"https:\/\/sqlnuggets.com\/powershell-compare-users-ad-groups\/","title":{"rendered":"PowerShell: Compare Users&#8217; AD Groups"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2021\/04\/patrick-fore-ZmH0g1ievTg-unsplash.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2021\/04\/patrick-fore-ZmH0g1ievTg-unsplash-1024x683.jpg\" alt=\"\" class=\"wp-image-1608\" srcset=\"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2021\/04\/patrick-fore-ZmH0g1ievTg-unsplash-1024x683.jpg 1024w, https:\/\/sqlnuggets.com\/wp-content\/uploads\/2021\/04\/patrick-fore-ZmH0g1ievTg-unsplash-300x200.jpg 300w, https:\/\/sqlnuggets.com\/wp-content\/uploads\/2021\/04\/patrick-fore-ZmH0g1ievTg-unsplash-768x512.jpg 768w, https:\/\/sqlnuggets.com\/wp-content\/uploads\/2021\/04\/patrick-fore-ZmH0g1ievTg-unsplash-1536x1024.jpg 1536w, https:\/\/sqlnuggets.com\/wp-content\/uploads\/2021\/04\/patrick-fore-ZmH0g1ievTg-unsplash.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>When it comes to user logins and permissions in SQL Server, I typically prefer to use Active Directory groups.  The problem with that is that you don&#8217;t always know what groups a given user is in.  I recently had a case where I needed to compare the Active Directory Groups of 2 users and determine which AD Groups both users were in.  As it turns out, with a little prep work this is really easy to do in PowerShell. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">The Prep<\/h4>\n\n\n\n<p>The easiest way to do this in PowerShell is with the <a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/activedirectory\/\" target=\"_blank\" rel=\"noreferrer noopener\">ActiveDirectory module<\/a>.  The installation of the AD module varies significantly for the different Windows and PowerShell versions, but for Windows 8 and 10, you just have to install the Remote Server Administration Tools (RSAT) from Microsoft.  <a href=\"https:\/\/4sysops.com\/wiki\/how-to-install-the-powershell-active-directory-module\/\" target=\"_blank\" rel=\"noreferrer noopener\">Here is a really good walkthrough of the various installs<\/a>. <\/p>\n\n\n\n<p>Once you get RSAT installed, you&#8217;ll have to run the following command to import the AD module into PowerShell.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import-module activedirectory<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">The Code<\/h4>\n\n\n\n<p>Once you have the AD module imported, you can call commands that interface directly with AD.  Here are some of the simple ones:<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Check an AD User account<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-ADUser 'Homer.Simpson'<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Check an AD Group<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>Get-ADGroupMember -Identity 'the-simpsons'<\/code><\/pre>\n\n\n\n<p>In my particular case, I needed to find out which groups were shared by 2 particular users.  I was easily able to do this by storing the results of <a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/activedirectory\/get-adprincipalgroupmembership\" target=\"_blank\" rel=\"noreferrer noopener\">Get-ADPrincipalGroupMembership<\/a> for each user, and then using <a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/microsoft.powershell.utility\/compare-object\" target=\"_blank\" rel=\"noreferrer noopener\">Compare-Object<\/a> to show which AD Groups matched. <\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Compare Users\u2019 AD Groups<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>$user1 = 'Homer.Simpson'\n$user2 = 'Barney.Gumble'\n\n$u1g = Get-ADPrincipalGroupMembership $user1 | select name\n$u2g = Get-ADPrincipalGroupMembership $user2 | select name\n\n\nCompare-Object -ReferenceObject $u1g -DifferenceObject $u2g -IncludeEqual -PassThru -ExcludeDifferent | SELECT Name\n<\/code><\/pre>\n\n\n\n<p>As it turns out, for those that are curious, &#8220;Moe&#8217;s Tavern&#8221; was the only group these 2 users shared. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>When it comes to user logins and permissions in SQL Server, I typically prefer to use Active Directory groups. The problem with that is that you don&#8217;t always know what &#8230;<\/p>\n","protected":false},"author":2,"featured_media":1608,"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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[20],"tags":[39,17],"class_list":["post-1604","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-internals","tag-server-administration"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PowerShell: Compare Users&#039; AD Groups - 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\/powershell-compare-users-ad-groups\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PowerShell: Compare Users&#039; AD Groups - SQL Nuggets\" \/>\n<meta property=\"og:description\" content=\"When it comes to user logins and permissions in SQL Server, I typically prefer to use Active Directory groups. The problem with that is that you don&#8217;t always know what ...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.sqlnuggets.com\/powershell-compare-users-ad-groups\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Nuggets\" \/>\n<meta property=\"article:published_time\" content=\"2021-04-15T16:20:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-20T13:31:50+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.sqlnuggets.com\/wp-content\/uploads\/2021\/04\/patrick-fore-ZmH0g1ievTg-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1280\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\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\\\/powershell-compare-users-ad-groups\\\/#article\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/powershell-compare-users-ad-groups\\\/\"},\"author\":{\"name\":\"Eric Cobb\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#\\\/schema\\\/person\\\/210536254addbc1b9d2d95dc1448b38a\"},\"headline\":\"PowerShell: Compare Users&#8217; AD Groups\",\"datePublished\":\"2021-04-15T16:20:00+00:00\",\"dateModified\":\"2021-04-20T13:31:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/powershell-compare-users-ad-groups\\\/\"},\"wordCount\":257,\"commentCount\":1,\"publisher\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#organization\"},\"image\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/powershell-compare-users-ad-groups\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/patrick-fore-ZmH0g1ievTg-unsplash.jpg\",\"keywords\":[\"Internals\",\"Server Administration\"],\"articleSection\":[\"PowerShell\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\\\/\\\/www.sqlnuggets.com\\\/powershell-compare-users-ad-groups\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/powershell-compare-users-ad-groups\\\/\",\"url\":\"http:\\\/\\\/www.sqlnuggets.com\\\/powershell-compare-users-ad-groups\\\/\",\"name\":\"PowerShell: Compare Users' AD Groups - SQL Nuggets\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/powershell-compare-users-ad-groups\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/powershell-compare-users-ad-groups\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/patrick-fore-ZmH0g1ievTg-unsplash.jpg\",\"datePublished\":\"2021-04-15T16:20:00+00:00\",\"dateModified\":\"2021-04-20T13:31:50+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/powershell-compare-users-ad-groups\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/www.sqlnuggets.com\\\/powershell-compare-users-ad-groups\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/powershell-compare-users-ad-groups\\\/#primaryimage\",\"url\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/patrick-fore-ZmH0g1ievTg-unsplash.jpg\",\"contentUrl\":\"https:\\\/\\\/sqlnuggets.com\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/patrick-fore-ZmH0g1ievTg-unsplash.jpg\",\"width\":1920,\"height\":1280},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/www.sqlnuggets.com\\\/powershell-compare-users-ad-groups\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\\\/\\\/www.sqlnuggets.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PowerShell: Compare Users&#8217; AD Groups\"}]},{\"@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":"PowerShell: Compare Users' AD Groups - 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\/powershell-compare-users-ad-groups\/","og_locale":"en_US","og_type":"article","og_title":"PowerShell: Compare Users' AD Groups - SQL Nuggets","og_description":"When it comes to user logins and permissions in SQL Server, I typically prefer to use Active Directory groups. The problem with that is that you don&#8217;t always know what ...","og_url":"http:\/\/www.sqlnuggets.com\/powershell-compare-users-ad-groups\/","og_site_name":"SQL Nuggets","article_published_time":"2021-04-15T16:20:00+00:00","article_modified_time":"2021-04-20T13:31:50+00:00","og_image":[{"width":1920,"height":1280,"url":"http:\/\/www.sqlnuggets.com\/wp-content\/uploads\/2021\/04\/patrick-fore-ZmH0g1ievTg-unsplash.jpg","type":"image\/jpeg"}],"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\/powershell-compare-users-ad-groups\/#article","isPartOf":{"@id":"http:\/\/www.sqlnuggets.com\/powershell-compare-users-ad-groups\/"},"author":{"name":"Eric Cobb","@id":"http:\/\/www.sqlnuggets.com\/#\/schema\/person\/210536254addbc1b9d2d95dc1448b38a"},"headline":"PowerShell: Compare Users&#8217; AD Groups","datePublished":"2021-04-15T16:20:00+00:00","dateModified":"2021-04-20T13:31:50+00:00","mainEntityOfPage":{"@id":"http:\/\/www.sqlnuggets.com\/powershell-compare-users-ad-groups\/"},"wordCount":257,"commentCount":1,"publisher":{"@id":"http:\/\/www.sqlnuggets.com\/#organization"},"image":{"@id":"http:\/\/www.sqlnuggets.com\/powershell-compare-users-ad-groups\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2021\/04\/patrick-fore-ZmH0g1ievTg-unsplash.jpg","keywords":["Internals","Server Administration"],"articleSection":["PowerShell"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/www.sqlnuggets.com\/powershell-compare-users-ad-groups\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/www.sqlnuggets.com\/powershell-compare-users-ad-groups\/","url":"http:\/\/www.sqlnuggets.com\/powershell-compare-users-ad-groups\/","name":"PowerShell: Compare Users' AD Groups - SQL Nuggets","isPartOf":{"@id":"http:\/\/www.sqlnuggets.com\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.sqlnuggets.com\/powershell-compare-users-ad-groups\/#primaryimage"},"image":{"@id":"http:\/\/www.sqlnuggets.com\/powershell-compare-users-ad-groups\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2021\/04\/patrick-fore-ZmH0g1ievTg-unsplash.jpg","datePublished":"2021-04-15T16:20:00+00:00","dateModified":"2021-04-20T13:31:50+00:00","breadcrumb":{"@id":"http:\/\/www.sqlnuggets.com\/powershell-compare-users-ad-groups\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.sqlnuggets.com\/powershell-compare-users-ad-groups\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.sqlnuggets.com\/powershell-compare-users-ad-groups\/#primaryimage","url":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2021\/04\/patrick-fore-ZmH0g1ievTg-unsplash.jpg","contentUrl":"https:\/\/sqlnuggets.com\/wp-content\/uploads\/2021\/04\/patrick-fore-ZmH0g1ievTg-unsplash.jpg","width":1920,"height":1280},{"@type":"BreadcrumbList","@id":"http:\/\/www.sqlnuggets.com\/powershell-compare-users-ad-groups\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.sqlnuggets.com\/"},{"@type":"ListItem","position":2,"name":"PowerShell: Compare Users&#8217; AD Groups"}]},{"@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\/2021\/04\/patrick-fore-ZmH0g1ievTg-unsplash.jpg","jetpack_shortlink":"https:\/\/wp.me\/pdyDvE-pS","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":600,"url":"https:\/\/sqlnuggets.com\/notes-sql-2017-azure-install-using-group-managed-service-accounts\/","url_meta":{"origin":1604,"position":0},"title":"Notes From A SQL 2017 Azure Install &#8211; Using Group Managed Service Accounts","author":"Eric Cobb","date":"November 7, 2017","format":false,"excerpt":"One of the new features that I'm excited about implementing on my Windows 2016 SQL Server 2017 servers is the ability to use\u00a0Group Managed Service Accounts, or \"gMSA\" for short.\u00a0 This isn't really a new feature, I believe it was first made available for SQL Server 2014 running on Windows\u2026","rel":"","context":"In &quot;Availability Groups&quot;","block_context":{"text":"Availability Groups","link":"https:\/\/sqlnuggets.com\/category\/availability-groups\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/10\/Cloud-Azure.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/10\/Cloud-Azure.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/10\/Cloud-Azure.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2017\/10\/Cloud-Azure.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":341,"url":"https:\/\/sqlnuggets.com\/calling-powershell-from-sql-agent-gives-syntax-error\/","url_meta":{"origin":1604,"position":1},"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":1049,"url":"https:\/\/sqlnuggets.com\/patching-multiple-sql-servers-with-powershell-and-dbatools\/","url_meta":{"origin":1604,"position":2},"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":[]},{"id":1513,"url":"https:\/\/sqlnuggets.com\/upcoming-geek-sync-practical-powershell-for-the-busy-dba\/","url_meta":{"origin":1604,"position":3},"title":"Upcoming Geek Sync: Practical PowerShell For The Busy DBA","author":"Eric Cobb","date":"November 10, 2020","format":false,"excerpt":"Be sure to sign up for my upcoming IDERA Geek Sync, Practical PowerShell For The Busy DBA on November 19th, 2020 at 11:00 AM CT. I will be focusing on using the dbatools PowerShell module, and show just how great it is at handling many of the tasks that SQL\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\/2020\/11\/EmZ1VIOWMAMIy-r.jpeg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/11\/EmZ1VIOWMAMIy-r.jpeg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/11\/EmZ1VIOWMAMIy-r.jpeg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/11\/EmZ1VIOWMAMIy-r.jpeg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/11\/EmZ1VIOWMAMIy-r.jpeg?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/sqlnuggets.com\/wp-content\/uploads\/2020\/11\/EmZ1VIOWMAMIy-r.jpeg?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":870,"url":"https:\/\/sqlnuggets.com\/getting-started-with-the-dbatools-powershell-module\/","url_meta":{"origin":1604,"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":842,"url":"https:\/\/sqlnuggets.com\/using-powershell-to-list-folders-and-sizes\/","url_meta":{"origin":1604,"position":5},"title":"Using PowerShell To List Folders And Sizes","author":"Eric Cobb","date":"July 24, 2018","format":false,"excerpt":"One of the things I run into regularly when dealing with storage is needing to know the sizes of folders in a directory.\u00a0 For example, if something filled up a drive over night, and you have 50 directories on that drive, which one did it? Thankfully, PowerShell makes it easy\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\/1604","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=1604"}],"version-history":[{"count":6,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/posts\/1604\/revisions"}],"predecessor-version":[{"id":1627,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/posts\/1604\/revisions\/1627"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/media\/1608"}],"wp:attachment":[{"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/media?parent=1604"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/categories?post=1604"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlnuggets.com\/wp-json\/wp\/v2\/tags?post=1604"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}