Jump to content

Recommended Posts

Posted

I want to be able to grab the serial number of the system with a WMI script and use newsid from sysinternals to assign a new SID as well as rename the computer.

The computer name must follow the following format:

XXXXMTHY

Where XXXX is the last 4 digits of the serial number of the system

MTH is the current month

and Y is the current year.

I have seen a few topics relating to this here, but haven't been able to completely accomplish it yet. Hardest part is grabbing just the last 4 digits of the serial number. Any help would be appreciated.


Posted

well if you are using WMI and a VBscript the use the RIGHT(String$,x) command to get the last four characters of the serial number. Then append the month and year to the results.

Posted

Nice, thanks! This is what I have, now I have to figure how to put this result into newsid and I'm finished!

Dim objWMI : Set objWMI = GetObject("winmgmts:")
Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
Dim colSettingsBios : Set colSettingsBios = objWMI.ExecQuery("Select * from Win32_BIOS")
Dim objComputer, strSerial
For Each objComputer in colSettingsBios
strSerial = right(objComputer.SerialNumber,4) & UCase(MonthName(month(date),true)) & right((Year(Date)),1)

Posted

Not too sure if the next line would work for the newsid command, haven't got a box to test it on just yet. Can anyone confirm?

Set objShell = CreateObject("WScript.Shell")
Set objScriptExec = objShell.Exec("newsid /a " & strSerial)

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
  • Recently Browsing   0 members

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