Jump to content

New to IT Scripting, question here


Recommended Posts

Hey everyone, just joined the board here and I have a quick question. My company uses AutoIT for scripting and deployment on multiple machines (a few hundred approx). I have read the forums and did find a

snippet of code that appears to pertain to my question. The code is below;

$OldUser = "Guest" $NewUser = "Guestrenamed"

$oUser = ObjGet("WinNT://" & @ComputerName & "/" & $OldUser & ",user")

$oComputer = ObjGet("WinNT://" & @ComputerName) $oNewUser = $oComputer.MoveHere($oUser.ADsPath, $NewUser)

I am trying to find a script that will allow me to rename the admin and guest accounts on about 225 computers by just changing the name in the script and applying it to all 225 computers, rather than doing so

manually. I am new to AutoIt and scripting in general, but I believe the code above may be what I am looking for. My question is, do I just run the script above after saving it? If editing is necessary what parts would I

need to edit. I assume it goes by computer name. So, say for instance my computer name was DXC2245, where would I put that into the code? Also, will that snippet of code work for what I want? Thank you in

advance.

Link to comment
Share on other sites

Welcome to AutoIt and the forum!

In short:

Replace @ComputerName with the name of the computer you want to connect to (e.g. "DXC2245").

You need to implement some error checks to make sure the script runs successfully. That means check the error macro @error and define a COM error handler to get as much error information as possbible.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hi water, ty for the response. I understand now that I need to replace @ComputerName with the computer I am trying to connect to, but what if I want to deploy this change to 225 computers? Do I have to put all 225 computer names in that spot, or is there a command/parameter etc. that will allow me to target all computers on the domain? I notice it says WinNT and the computers where I work all run Win XP Pro, so would I need to change that? Sorry, very new to this.

Link to comment
Share on other sites

It depends.

Where do you have the 225 computer names stored right now? Active Directory, a text file ..?

You don't have to change "WinNT://" to XP, it's the provider name.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

New to scripting... and being a computer/network admin?

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

New to scripting... and being a computer/network admin?

I am not the admin, I help our sys admin with some tasks when he gets bogged down. I could rename them all manually, but I am trying to learn how to do this via script to make it easier on myself for the future.

Link to comment
Share on other sites

Then it's easy. ;)

You could use my Active Directory UDF (for download please see my signature) to retrieve a list of computers and store it in an array. Then loop through the array and do the rename job.

Make sure to handle errors as I described above.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Maybe the by Water? Never used it so not sure of its capabilities.

Edit:

This post is all wet.

Edited by mechaflash213
Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

techno81,

I am quoting you! Your question is alarming at several levels so am offering friendly advice.

Good Luck,

kylomas

Not sure how it is alarming. I work for a business, where I have ran scripts for my colleague (system Admin that he wrote) to essentially deploy updates to a group of machines. I am just wanting to be able to change the names of the admin accounts and guest accounts for auditing purposes. Instead of administrator and guest, I am trying to find a script that will allow me to rename all 225 machines via deployment so I do not have to do it manually. Sorry.

Link to comment
Share on other sites

I think he meant talk with your admins/team members etc.

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

techno81,

No need to apologize, your origional post asked questions that lead me to believe that you wanted a mechanism for bulk changes without knowing the infrastructure, including any change management in place. I hope I am mistaken and you simply need programming direction.

Good Luck,

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

if you use group policy in Active Directory, you can disable the guest accounts and change the Administrator account names from a group policy, it's 2 settings and will happen every time the computer reboots, if it hasn't been done already.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

techno81,

No need to apologize, your origional post asked questions that lead me to believe that you wanted a mechanism for bulk changes without knowing the infrastructure, including any change management in place. I hope I am mistaken and you simply need programming direction.

Good Luck,

kylomas

Hey Kylomas, no I totally understand and thanks for looking out. As for me, we do have a system we use for change requests involving big updates. My system admin is the one who actually wants me to do this so I got instructions from him. I simply just needed direction on how programmatically I could conjure a script to change multiple admin/guest accounts at once. I am familiar with the infrastructure, and have a total understanding of what I can and cannot do. This is just being done to mitigate the workload my system admin already has. I guess you can call it a kind gesture ;) as I could just tell him no way that is your job (without being fired as he is not who I report to) but I want to learn and doing different work at different times is best way to do so.

Link to comment
Share on other sites

if you use group policy in Active Directory, you can disable the guest accounts and change the Administrator account names from a group policy, it's 2 settings and will happen every time the computer reboots, if it hasn't been done already.

Brewman, our guests accounts are disabled and we do use group policy with active directory. What two settings are you referring to please?

Link to comment
Share on other sites

I think the two settings as described by Reg2Post in post #16.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...