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
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
add a comment |
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
add a comment |
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
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
powershell
edited Mar 21 at 19:32
Ansgar Wiechers
146k13132190
146k13132190
asked Mar 21 at 18:43
Dev Ops 52Dev Ops 52
1
1
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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]
add a comment |
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
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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]
add a comment |
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]
add a comment |
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]
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]
answered Mar 21 at 19:42
Lee_DaileyLee_Dailey
2,5911811
2,5911811
add a comment |
add a comment |
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
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.
add a comment |
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
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.
add a comment |
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
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
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.
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.
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
