How to use Win32_UserAccount rename method? The Next CEO of Stack OverflowHow to run a PowerShell scriptHow do you comment out code in PowerShell?How to filter Win32_UserAccount results by OUWMI IIS 6.0 Custom HttpError (Powershell)PowerShell Rename-Computer issue — names with underscoresScript to add days to a parameterUsing Powershells Trimstart to remove array of characters from filenameError in executing Exchange PS remoting: Method invocation failed?Powershell Exception: Not enough quota is available to process this commandPSWindowsUpdate File Not Found Exception

Does higher Oxidation/ reduction potential translate to higher energy storage in battery?

Audio Conversion With ADS1243

Is fine stranded wire ok for main supply line?

Is it okay to majorly distort historical facts while writing a fiction story?

How did Beeri the Hittite come up with naming his daughter Yehudit?

Can I calculate next year's exemptions based on this year's refund/amount owed?

Help/tips for a first time writer?

Could a dragon use its wings to swim?

Is it ever safe to open a suspicious HTML file (e.g. email attachment)?

Easy to read palindrome checker

What CSS properties can the br tag have?

Is a distribution that is normal, but highly skewed, considered Gaussian?

Small nick on power cord from an electric alarm clock, and copper wiring exposed but intact

From jafe to El-Guest

Is it ok to trim down a tube patch?

Reshaping json / reparing json inside shell script (remove trailing comma)

What does "shotgun unity" refer to here in this sentence?

Which one is the true statement?

Getting Stale Gas Out of a Gas Tank w/out Dropping the Tank

Can Sneak Attack be used when hitting with an improvised weapon?

Do scriptures give a method to recognize a truly self-realized person/jivanmukta?

What are the unusually-enlarged wing sections on this P-38 Lightning?

Where do students learn to solve polynomial equations these days?

Why do we say 'Un seul M' and not 'Une seule M' even though M is a "consonne"



How to use Win32_UserAccount rename method?



The Next CEO of Stack OverflowHow to run a PowerShell scriptHow do you comment out code in PowerShell?How to filter Win32_UserAccount results by OUWMI IIS 6.0 Custom HttpError (Powershell)PowerShell Rename-Computer issue — names with underscoresScript to add days to a parameterUsing Powershells Trimstart to remove array of characters from filenameError in executing Exchange PS remoting: Method invocation failed?Powershell Exception: Not enough quota is available to process this commandPSWindowsUpdate File Not Found Exception










0















I am able to use Get-CimInstance Win32_UserAccount to list users on remote computers. Once I get the users, I would like to rename the administrator account. Below is the code but it does not work. Any tips on making this work?



$hostname = "SERVER1"
$newname = "Server_Admin"
$administrator = Get-CimInstance Win32_UserAccount -ComputerName $hostname |
where SID -like 'S-1-5-*-500' -ErrorAction SilentlyContinue
$oldname = $administrator.Name

$oldname.Rename($newname)


Above command failed with the error




Method invocation failed because [System.String] does not contain a method named 'rename'.




Using Set-CimInstance



Set-CimInstance -InputObject $administrator -Property @name=$newname -PassThru


gives an error




Could not modify readonly property 'name' of object 'Win32_UserAccount"




PowerShell version used is 5.1.










share|improve this question




























    0















    I am able to use Get-CimInstance Win32_UserAccount to list users on remote computers. Once I get the users, I would like to rename the administrator account. Below is the code but it does not work. Any tips on making this work?



    $hostname = "SERVER1"
    $newname = "Server_Admin"
    $administrator = Get-CimInstance Win32_UserAccount -ComputerName $hostname |
    where SID -like 'S-1-5-*-500' -ErrorAction SilentlyContinue
    $oldname = $administrator.Name

    $oldname.Rename($newname)


    Above command failed with the error




    Method invocation failed because [System.String] does not contain a method named 'rename'.




    Using Set-CimInstance



    Set-CimInstance -InputObject $administrator -Property @name=$newname -PassThru


    gives an error




    Could not modify readonly property 'name' of object 'Win32_UserAccount"




    PowerShell version used is 5.1.










    share|improve this question


























      0












      0








      0








      I am able to use Get-CimInstance Win32_UserAccount to list users on remote computers. Once I get the users, I would like to rename the administrator account. Below is the code but it does not work. Any tips on making this work?



      $hostname = "SERVER1"
      $newname = "Server_Admin"
      $administrator = Get-CimInstance Win32_UserAccount -ComputerName $hostname |
      where SID -like 'S-1-5-*-500' -ErrorAction SilentlyContinue
      $oldname = $administrator.Name

      $oldname.Rename($newname)


      Above command failed with the error




      Method invocation failed because [System.String] does not contain a method named 'rename'.




      Using Set-CimInstance



      Set-CimInstance -InputObject $administrator -Property @name=$newname -PassThru


      gives an error




      Could not modify readonly property 'name' of object 'Win32_UserAccount"




      PowerShell version used is 5.1.










      share|improve this question
















      I am able to use Get-CimInstance Win32_UserAccount to list users on remote computers. Once I get the users, I would like to rename the administrator account. Below is the code but it does not work. Any tips on making this work?



      $hostname = "SERVER1"
      $newname = "Server_Admin"
      $administrator = Get-CimInstance Win32_UserAccount -ComputerName $hostname |
      where SID -like 'S-1-5-*-500' -ErrorAction SilentlyContinue
      $oldname = $administrator.Name

      $oldname.Rename($newname)


      Above command failed with the error




      Method invocation failed because [System.String] does not contain a method named 'rename'.




      Using Set-CimInstance



      Set-CimInstance -InputObject $administrator -Property @name=$newname -PassThru


      gives an error




      Could not modify readonly property 'name' of object 'Win32_UserAccount"




      PowerShell version used is 5.1.







      powershell






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 21 at 19:32









      Ansgar Wiechers

      146k13132190




      146k13132190










      asked Mar 21 at 18:43









      Dev Ops 52Dev Ops 52

      1




      1






















          2 Answers
          2






          active

          oldest

          votes


















          0














          in that use case, the CIM cmdlet DOES NOT return a live object. there is NO .Rename() method attached to that object.



          however, the WMI cmdlet DOES return a live object with a .Rename() method. so ... use Get-WmiObject -Class Win32_UserAccount instead of Get-CimInstance -ClassName Win32_UserAccount. [grin]






          share|improve this answer






























            0














            Using PowerShell version 5.1



            Using Invoke-CIMMethod I was able to rename the account.



            $serverlist = Get-Content C:Tempservers.txt
            $newname = "Server_Admin"

            foreach ($hostname in $serverlist)

            #Check if server is online.
            if (Test-Connection -ComputerName $hostname -Count 1 -Delay 2 -BufferSize 1452 -Quiet)
            sort Status






            share|improve this answer








            New contributor




            Dev Ops 52 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.




















              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55287254%2fhow-to-use-win32-useraccount-rename-method%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              in that use case, the CIM cmdlet DOES NOT return a live object. there is NO .Rename() method attached to that object.



              however, the WMI cmdlet DOES return a live object with a .Rename() method. so ... use Get-WmiObject -Class Win32_UserAccount instead of Get-CimInstance -ClassName Win32_UserAccount. [grin]






              share|improve this answer



























                0














                in that use case, the CIM cmdlet DOES NOT return a live object. there is NO .Rename() method attached to that object.



                however, the WMI cmdlet DOES return a live object with a .Rename() method. so ... use Get-WmiObject -Class Win32_UserAccount instead of Get-CimInstance -ClassName Win32_UserAccount. [grin]






                share|improve this answer

























                  0












                  0








                  0







                  in that use case, the CIM cmdlet DOES NOT return a live object. there is NO .Rename() method attached to that object.



                  however, the WMI cmdlet DOES return a live object with a .Rename() method. so ... use Get-WmiObject -Class Win32_UserAccount instead of Get-CimInstance -ClassName Win32_UserAccount. [grin]






                  share|improve this answer













                  in that use case, the CIM cmdlet DOES NOT return a live object. there is NO .Rename() method attached to that object.



                  however, the WMI cmdlet DOES return a live object with a .Rename() method. so ... use Get-WmiObject -Class Win32_UserAccount instead of Get-CimInstance -ClassName Win32_UserAccount. [grin]







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 21 at 19:42









                  Lee_DaileyLee_Dailey

                  2,5911811




                  2,5911811























                      0














                      Using PowerShell version 5.1



                      Using Invoke-CIMMethod I was able to rename the account.



                      $serverlist = Get-Content C:Tempservers.txt
                      $newname = "Server_Admin"

                      foreach ($hostname in $serverlist)

                      #Check if server is online.
                      if (Test-Connection -ComputerName $hostname -Count 1 -Delay 2 -BufferSize 1452 -Quiet)
                      sort Status






                      share|improve this answer








                      New contributor




                      Dev Ops 52 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.
























                        0














                        Using PowerShell version 5.1



                        Using Invoke-CIMMethod I was able to rename the account.



                        $serverlist = Get-Content C:Tempservers.txt
                        $newname = "Server_Admin"

                        foreach ($hostname in $serverlist)

                        #Check if server is online.
                        if (Test-Connection -ComputerName $hostname -Count 1 -Delay 2 -BufferSize 1452 -Quiet)
                        sort Status






                        share|improve this answer








                        New contributor




                        Dev Ops 52 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.






















                          0












                          0








                          0







                          Using PowerShell version 5.1



                          Using Invoke-CIMMethod I was able to rename the account.



                          $serverlist = Get-Content C:Tempservers.txt
                          $newname = "Server_Admin"

                          foreach ($hostname in $serverlist)

                          #Check if server is online.
                          if (Test-Connection -ComputerName $hostname -Count 1 -Delay 2 -BufferSize 1452 -Quiet)
                          sort Status






                          share|improve this answer








                          New contributor




                          Dev Ops 52 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.










                          Using PowerShell version 5.1



                          Using Invoke-CIMMethod I was able to rename the account.



                          $serverlist = Get-Content C:Tempservers.txt
                          $newname = "Server_Admin"

                          foreach ($hostname in $serverlist)

                          #Check if server is online.
                          if (Test-Connection -ComputerName $hostname -Count 1 -Delay 2 -BufferSize 1452 -Quiet)
                          sort Status







                          share|improve this answer








                          New contributor




                          Dev Ops 52 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          share|improve this answer



                          share|improve this answer






                          New contributor




                          Dev Ops 52 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          answered Mar 25 at 20:16









                          Dev Ops 52Dev Ops 52

                          1




                          1




                          New contributor




                          Dev Ops 52 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.





                          New contributor





                          Dev Ops 52 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






                          Dev Ops 52 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55287254%2fhow-to-use-win32-useraccount-rename-method%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                              용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                              155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해