PS script to rename workstation

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of Olaf Soyk Olaf Soyk 1 month, 1 week ago.

  • Author
    Posts
  • #56344
    Profile photo of Thundercat
    Thundercat
    Participant

    Hi,

    I'm looking to create a PS script that renames a Dell workstation(s) in the following format MODELNumber-SERVICETAG (eg. E5570-123ABC1). I have managed to retrieve the service tag using the following command;

    Get-WmiObject win32_bios | Select-Object -ExpandProperty SerialNumber

    I'm unsure how to retrieve just the model number and then put that information before the service tag. I would also like to seperate this with a hyphen.

    I'm a novice with PS and any help will be much appreciated with creating a rename workstation script.

    Regards,
    Thundercat

  • #56345
    Profile photo of Olaf Soyk
    Olaf Soyk
    Participant

    Should work with something like this:

    $SerialNo = (Get-CimInstance -ClassName CIM_BIOSElement).SerialNumber
    $ModelNo = (Get-CimInstance -ClassName CIM_ComputerSystem).Model.Split(' ').[1]
    $NewDellWorkstationName = $ModelNo + '-' + $SerialNo
    
  • #56351
    Profile photo of Thundercat
    Thundercat
    Participant

    Thanks for your reply, I get the following message when I test the script;

    PS R:\> $SerialNo = (Get-CimInstance -ClassName CIM_BIOSElement).SerialNumber
    $ModelNo = (Get-CimInstance -ClassName CIM_ComputerSystem).Model.Split(' ').[1]
    $NewDellWorkstationName = $ModelNo + '-' + $SerialNo
    The term 'Get-CimInstance' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:29
    + $SerialNo = (Get-CimInstance <<<< -ClassName CIM_BIOSElement).SerialNumber + CategoryInfo : ObjectNotFound: (Get-CimInstance:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException The term 'Get-CimInstance' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:2 char:28 + $ModelNo = (Get-CimInstance <<<< -ClassName CIM_ComputerSystem).Model.Split(' ').[1] + CategoryInfo : ObjectNotFound: (Get-CimInstance:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException I'm running PS on a Windows 7 workstation. Regards, Thundercat

  • #56354
    Profile photo of Olaf Soyk
    Olaf Soyk
    Participant

    So you're using an older version of Powershell. What a pity. 😉 But not a problem either:

    $SerialNo = (Get-WMIObject -Class WIN32_BIOS).SerialNumber
    $ModelNo = (Get-WMIObject -Class WIN32_ComputerSystem).Model.Split(' ').[1]
    $NewDellWorkstationName = $ModelNo + '-' + $SerialNo
    

You must be logged in to reply to this topic.