{"id":3789,"date":"2014-04-15T09:14:03","date_gmt":"2014-04-15T13:14:03","guid":{"rendered":"http:\/\/jdhitsolutions.com\/blog\/?p=3789"},"modified":"2014-04-15T09:14:03","modified_gmt":"2014-04-15T13:14:03","slug":"set-local-user-account-with-powershell","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/","title":{"rendered":"Set Local User Account with PowerShell"},"content":{"rendered":"<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/halfuser.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-3790\" alt=\"halfuser\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/halfuser-190x300.png\" width=\"190\" height=\"300\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/halfuser-190x300.png 190w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/halfuser.png 254w\" sizes=\"auto, (max-width: 190px) 100vw, 190px\" \/><\/a> The other day I received an email from a student asking for some help in using PowerShell to take care of a user account on a local computer. He not only wanted to be able to set the password, which he had already figured out, but also how to enable or disable the account, which is not obvious or intuitive without experience using ADSI and the WinNT provider. I sent him some suggestions to get him started down the right path. But I realized, I should wrap up this functionality in a PowerShell tool since his task is something I assume many of you need and there are no cmdlets from Microsoft for managing local user accounts.<\/p>\n<p>First, let me point out that it is actually quite easy to manage local user accounts on remote computers using PowerShell. All you need to do is learn how to use the NET USER command and execute it using Invoke-Command.<\/p>\n<pre class=\"lang:ps decode:true \" >invoke-command { net user } -computername chi-core01<\/pre>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/remote-net-user-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/remote-net-user-1-300x72.png\" alt=\"remote-net-user-1\" width=\"300\" height=\"72\" class=\"aligncenter size-medium wp-image-3792\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/remote-net-user-1-300x72.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/remote-net-user-1.png 929w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<pre class=\"lang:ps decode:true \" >invoke-command { net user localadmin } -computername chi-core01<\/pre>\n<p><a href=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/remote-net-user-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/remote-net-user-2-300x162.png\" alt=\"remote-net-user-2\" width=\"300\" height=\"162\" class=\"aligncenter size-medium wp-image-3793\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/remote-net-user-2-300x162.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/remote-net-user-2.png 956w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The LocalAdmin account on CHI-CORE01 is currently disabled (account active is equal to no). But it is pretty easy to enable and set a new password.<\/p>\n<pre class=\"lang:ps decode:true \" >invoke-command { net user localadmin P@ssw0rd \/active:Yes } -computername chi-core01<\/pre>\n<p>However, this doesn't scale well and the capabilities of the NET USER command might vary by operating system. So here is a PowerShell function that utilizes ADSI to do the same thing.<\/p>\n<pre class=\"lang:ps decode:true \" >#requires -version 2.0\r\n\r\nFunction Set-LocalUserAccount {\r\n&lt;#\r\n.SYNOPSIS\r\nEnable or disable a local user account.\r\n\r\n.DESCRIPTION\r\nThis command will allow you to set the password of a local user account as well\r\nas enable or disable it. By default, this command will not write anything to\r\nthe pipeline unless you use -Passthru.  You must run this under credentials \r\nthat have administrator rights on the remote computer.\r\n\r\n.PARAMETER ComputerName \r\nThe name of the computer to connect to. This parameter has an alias of CN.\r\n.PARAMETER UserName \r\nThe name of the local user account on the computer.\r\n.PARAMETER Password \r\nThe new password to set. This parameter has an alias of PWD.\r\n.PARAMETER Status \r\nEnable or disable the local user account.\r\n.PARAMETER Passthru\r\nWrite the user account object to the pipeline\r\n.EXAMPLE\r\nPS C:\\&gt; Set-LocalUserAccount SERVER01,SERVER02 DBAdmin -status disable\r\n\r\nDisable the local user account DBAdmin on SERVER01 and SERVER02\r\n\r\n.EXAMPLE\r\nPS C:\\&gt; get-content c:\\work\\computers.txt | set-localuseraccount LocalAdmin -password \"^Crx33t7A\"\r\n\r\nSets the password for account LocalAdmin on all computers in computers.txt\r\n\r\n.NOTES\r\nVersion: 1.0\r\nAuthor : Jeff Hicks (@JeffHicks)\r\n\r\nLearn more:\r\n PowerShell in Depth: An Administrator's Guide (http:\/\/www.manning.com\/jones2\/)\r\n PowerShell Deep Dives (http:\/\/manning.com\/hicks\/)\r\n Learn PowerShell 3 in a Month of Lunches (http:\/\/manning.com\/jones3\/)\r\n Learn PowerShell Toolmaking in a Month of Lunches (http:\/\/manning.com\/jones4\/)\r\n\r\n\r\n  ****************************************************************\r\n  * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *\r\n  * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK.  IF   *\r\n  * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *\r\n  * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING.             *\r\n  ****************************************************************\r\n\r\n.INPUTS\r\nString\r\n.OUTPUTS\r\nNone or System.DirectoryServices.DirectoryEntry\r\n\r\n#&gt;\r\n\r\n[cmdletbinding(SupportsShouldProcess=$True)]\r\n\r\nParam (\r\n[Parameter(Position=0,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]\r\n[ValidateNotNullorEmpty()]\r\n[Alias(\"cn\")]\r\n[string[]]$ComputerName=$env:COMPUTERNAME, \r\n[Parameter(Position=1,Mandatory=$True,\r\nHelpMessage=\"What is the name of the local user account?\",\r\nValueFromPipelineByPropertyName=$True)]\r\n[ValidateNotNullorEmpty()]\r\n[string]$UserName, \r\n[Parameter(ValueFromPipelineByPropertyName=$True)]\r\n[Alias(\"pwd\")]\r\n[string]$Password, \r\n[ValidateSet(\"Enable\",\"Disable\")]\r\n[string]$Status=\"Enable\",\r\n[switch]$Passthru\r\n)\r\n\r\nBegin {\r\n    Write-Verbose \"Starting $($myinvocation.mycommand)\"\r\n    #define a constant to disable or enable an account\r\n    New-Variable ADS_UF_ACCOUNTDISABLE 0x0002 -Option Constant\r\n\r\n    Write-Verbose \"Setting local user account $username\"\r\n} #begin\r\n\r\nProcess {\r\n    foreach ($computer in $computername) {\r\n        Write-Verbose \"Connecting to $computer\"\r\n        Write-Verbose \"Getting user account\"\r\n\r\n        $Account = [ADSI]\"WinNT:\/\/$computer\/$username,user\"\r\n\r\n        #validate the user account was found\r\n        if (-NOT $Account.path) {\r\n            Write-Warning \"Failed to find $username on $computername\"\r\n            #bail out\r\n            Return\r\n        }\r\n\r\n        #Get current enabled\/disabled status\r\n        if ($Account.userflags.value -band $ADS_UF_ACCOUNTDISABLE) {\r\n          $Enabled = $False\r\n        }\r\n        else {\r\n          $Enabled = $True\r\n        }\r\n\r\n        Write-verbose \"Account enabled is $Enabled\"\r\n\r\n        if ($enabled -AND ($Status -eq \"Disable\")) {\r\n            Write-Verbose \"disabling the account\"\r\n            $value=$Account.userflags.value -bor $ADS_UF_ACCOUNTDISABLE\r\n            $Account.put(\"userflags\",$value)\r\n        }\r\n        elseif ((-NOT $enabled) -AND ($Status -eq \"Enable\")) {\r\n            Write-Verbose \"Enabling the account\"\r\n            $value=$Account.userflags.value -bxor $ADS_UF_ACCOUNTDISABLE\r\n            $Account.put(\"userflags\",$value)\r\n        }\r\n        else {\r\n            #account is already in the desired state\r\n            Write-Verbose \"No change necessary\"\r\n        }\r\n\r\n        if ($Password) {\r\n            Write-Verbose \"Setting acccount password\"\r\n            $Account.SetPassword($Password)\r\n        }\r\n    \r\n        #Whatif\r\n        if ($PSCmdlet.ShouldProcess(\"$computer\\$username\")) {\r\n            Write-Verbose \"Committing changes\"\r\n            $Account.SetInfo()\r\n         }\r\n         if ($Passthru) {\r\n            Write-Verbose \"Passing object to the pipeline\"\r\n            $Account\r\n\r\n         }\r\n    } #foreach\r\n} #process\r\n\r\nEnd {    \r\n    Write-Verbose \"Ending $($myinvocation.mycommand)\"\r\n} #end\r\n \r\n} #end Set-LocalUserAccount function\r\n<\/pre>\n<p>This function should work in PowerShell 2.0 and later. The help content includes some usage examples. You can use this command to simply change the user password, or change the password while enabling or disabling the account. Enabling and disabling is accomplished with a bitwise operation with the userflags value and a constant flag that indicates the account is disabled.<\/p>\n<p>There is probably more that could be added to the command such as setting the comment property and when the account expires. But I'll leave those changes to you for now.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The other day I received an email from a student asking for some help in using PowerShell to take care of a user account on a local computer. He not only wanted to be able to set the password, which he had already figured out, but also how to enable or disable the account, which&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Set Local User Account with #PowerShell http:\/\/wp.me\/p1nF6U-Z7","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":[72,4,8],"tags":[39,534,540],"class_list":["post-3789","post","type-post","status-publish","format-standard","hentry","category-commandline","category-powershell","category-scripting","tag-adsi","tag-powershell","tag-scripting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Set Local User Account with PowerShell &#8226; The Lonely Administrator<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Set Local User Account with PowerShell &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"The other day I received an email from a student asking for some help in using PowerShell to take care of a user account on a local computer. He not only wanted to be able to set the password, which he had already figured out, but also how to enable or disable the account, which...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2014-04-15T13:14:03+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/halfuser-190x300.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3789\\\/set-local-user-account-with-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3789\\\/set-local-user-account-with-powershell\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Set Local User Account with PowerShell\",\"datePublished\":\"2014-04-15T13:14:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3789\\\/set-local-user-account-with-powershell\\\/\"},\"wordCount\":313,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3789\\\/set-local-user-account-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/04\\\/halfuser-190x300.png\",\"keywords\":[\"ADSI\",\"PowerShell\",\"Scripting\"],\"articleSection\":[\"CommandLine\",\"PowerShell\",\"Scripting\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3789\\\/set-local-user-account-with-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3789\\\/set-local-user-account-with-powershell\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3789\\\/set-local-user-account-with-powershell\\\/\",\"name\":\"Set Local User Account with PowerShell &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3789\\\/set-local-user-account-with-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3789\\\/set-local-user-account-with-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/04\\\/halfuser-190x300.png\",\"datePublished\":\"2014-04-15T13:14:03+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3789\\\/set-local-user-account-with-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3789\\\/set-local-user-account-with-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3789\\\/set-local-user-account-with-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/04\\\/halfuser.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2014\\\/04\\\/halfuser.png\",\"width\":254,\"height\":400},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell\\\/3789\\\/set-local-user-account-with-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"CommandLine\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/commandline\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Set Local User Account with PowerShell\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Set Local User Account with PowerShell &#8226; The Lonely Administrator","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":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/","og_locale":"en_US","og_type":"article","og_title":"Set Local User Account with PowerShell &#8226; The Lonely Administrator","og_description":"The other day I received an email from a student asking for some help in using PowerShell to take care of a user account on a local computer. He not only wanted to be able to set the password, which he had already figured out, but also how to enable or disable the account, which...","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/","og_site_name":"The Lonely Administrator","article_published_time":"2014-04-15T13:14:03+00:00","og_image":[{"url":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/halfuser-190x300.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Set Local User Account with PowerShell","datePublished":"2014-04-15T13:14:03+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/"},"wordCount":313,"commentCount":2,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/halfuser-190x300.png","keywords":["ADSI","PowerShell","Scripting"],"articleSection":["CommandLine","PowerShell","Scripting"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/","name":"Set Local User Account with PowerShell &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/#primaryimage"},"thumbnailUrl":"http:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/halfuser-190x300.png","datePublished":"2014-04-15T13:14:03+00:00","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/halfuser.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2014\/04\/halfuser.png","width":254,"height":400},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3789\/set-local-user-account-with-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"CommandLine","item":"https:\/\/jdhitsolutions.com\/blog\/category\/commandline\/"},{"@type":"ListItem","position":2,"name":"Set Local User Account with PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":4857,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4857\/getting-local-user-accounts-the-powershell-way\/","url_meta":{"origin":3789,"position":0},"title":"Getting Local User Accounts the PowerShell Way","author":"Jeffery Hicks","date":"February 10, 2016","format":false,"excerpt":"It seems I'm always seeing requests and problems on getting local user accounts using PowerShell.\u00a0 However, even though we are at PowerShell 5.0,\u00a0 Microsoft has never released a set of cmdlets for managing local user accounts. So many of us have resorted to creating our own tools. I now have\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb.png?resize=525%2C300 1.5x"},"classes":[]},{"id":4908,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4908\/get-local-group-members-with-powershell\/","url_meta":{"origin":3789,"position":1},"title":"Get Local Group Members with PowerShell","author":"Jeffery Hicks","date":"February 17, 2016","format":false,"excerpt":"Recently I posted a function to get information about local user accounts. I received a lot of positive feedback so it seemed natural to take this the next step and create a similar function to enumerate or list members of a local group, such as Administrators. The function, Get-LocalGroupMember, also\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb-7.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb-7.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb-7.png?resize=525%2C300 1.5x"},"classes":[]},{"id":3513,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/3513\/managing-local-admin-with-powershell\/","url_meta":{"origin":3789,"position":2},"title":"Managing Local Admin with PowerShell","author":"Jeffery Hicks","date":"October 24, 2013","format":false,"excerpt":"Years ago when I was deep into VBScript and HTAs, I wrote a tool called PWDMan. It was an HTA that processed a list of computers and returned password age information for the local administrator account. It was also capable of setting a new account password. Apparently this is still\u2026","rel":"","context":"In &quot;CommandLine&quot;","block_context":{"text":"CommandLine","link":"https:\/\/jdhitsolutions.com\/blog\/category\/commandline\/"},"img":{"alt_text":"021913_2047_WordTest1.png","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2013\/02\/021913_2047_WordTest1.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1885,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/1885\/updating-multi-valued-active-directory-properties-part-1\/","url_meta":{"origin":3789,"position":3},"title":"Updating Multi-Valued Active Directory Properties Part 1","author":"Jeffery Hicks","date":"December 8, 2011","format":false,"excerpt":"Yesterday on Twitter, I got a tweet from @Docsmooth regarding how to update a multivalued property in Active Directory. There are a number of ways to handle this, especially from PowerShell naturally, so I tweeted one way in a series of tweets. But that's a hard way to learn something,\u2026","rel":"","context":"In &quot;Active Directory&quot;","block_context":{"text":"Active Directory","link":"https:\/\/jdhitsolutions.com\/blog\/category\/active-directory\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4918,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/4918\/get-local-group-members-revisited\/","url_meta":{"origin":3789,"position":4},"title":"Get Local Group Members Revisited","author":"Jeffery Hicks","date":"February 18, 2016","format":false,"excerpt":"The other day I posted an article and function that used ADSI and PowerShell to list members of a local group. I had a few people report an unusual error that I couldn't replicate. During the course of troubleshooting, I made a few changes to the original function to at\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"image","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb-9.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb-9.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2016\/02\/image_thumb-9.png?resize=525%2C300 1.5x"},"classes":[]},{"id":148,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/148\/order-managing-active-directory-with-windows-powershell-tfm-finally\/","url_meta":{"origin":3789,"position":5},"title":"Order Managing Active Directory with Windows PowerShell: TFM &#8211; Finally!","author":"Jeffery Hicks","date":"September 22, 2008","format":false,"excerpt":"Yes, its finally true. You can finally get your hands on Managing Active Directory with Windows PowerShell: TFM. The book is being printed so you can get your copy today. You can order it today at ScriptingOutpost.com in both print and ebook format. Or if you prefer the best of\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3789","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=3789"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/3789\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=3789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=3789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=3789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}