PSD icon indicating copy to clipboard operation
PSD copied to clipboard

Computername from trimmed %Serial:8%

Open Vosssi opened this issue 1 year ago • 3 comments

if i set OSDComputerName=PSD-%SERIAL:8% running on ESX-VM where Serial is 54 characters long that will result in Computername = PSD-Vmware-1

it maybe result from PSDWizzardNew.psm1 function Set-PSDWizardStringLength Line 4366 -> [string]$Str.Substring($length + 1)

maybe this would fix ? [string]$Str.Substring($Str.Length - $length )

but how can i change and test that ?

Vosssi avatar Nov 06 '24 14:11 Vosssi

It is the PSDWizardNew.psm1 doing this. For VM's I recommend not trying to use the serial but random. Use OSDComputerName=PSD-%RANDOM:8%. You could try OSDComputerName=PSD-%8:SERIAL% which reversed it and looks for the last eight

PowerShellCrack avatar Nov 07 '24 01:11 PowerShellCrack

I did some Testing on a Lenovo E15 with serial 12345678 OSDComputerName=TST-%SERIAL:4% -> TST-1234 OSDComputerName=TST-%4:SERIAL% -> TST-678

OSDComputerName=TST-%6:SERIAL% -> TST-8 OSDComputerName=TST-%2:SERIAL% -> TST-45678

seems that
%SERIAL:4% cuts of 4 charaters on the right %4:SERIAL% cuts of 5 charaters on the left %6:SERIAL% cuts of 7 charaters on the left

would´n it be great if it does "leave #Num of char" instead of "cut #num of char". We are running different Computer Vendors and for Naming Conventions it would be very useful to just have the last 8 Digits of Serial. This would result in complete Service Tag on Dell Systems, and on VMware in a "better serial" because the 50 Character long "VM-Ware 00 11 22 33 ..." will be truncated to the right most Part.

Still have the Idea of using the MAC as Computername in my head. When i use Properties=MacAddress001 OSDComputerName=PSD-%MacAddress001%" in customsettings.ini, i receive the MAC as AA:BB:CC:DD:EE:FF. Computername will result in PSD-AA:BB:CC:DD:EE:FF witch is to long to use.

Maybe i can adjust the Function Get-PSDWizardComputerName to that if %Macaddress% or %macaddress001% is passed in, the function removes the ":" from the MAC String, and cuts of Chars from the left or right, to get more Space for the Prefix.

But have to find a Solution for trimming/cutting because :11 will be heavy to find in aa:bb:cc:dd:ee:ff:11 or 11:aa:bb:cc:dd:ee:ff when aa can be anything from 00 to ff.

Maybe i can use Keyword Like :vendor and :unique to return only the left/right Part of MAC.

Do you think i´m on the right track with the keyword idea, and modifying the Get-PSDWizardComputerName function ? Or will some other Function overwrite the Computername ?

by the way, VMware and Hyper-v VM's both have the same issue with the very very long Serial Number.

Vosssi avatar Nov 07 '24 08:11 Vosssi

I think this is a bug you found; it should only grab the last 8 or first 8, not remove the 8. I will work to fix this. I will also look into adding other supported variables like you mentioned.

I've only tested with Hyper-V VM's, but I also wrote a script that modifies the VM's serial number and assettag to reflect "model" like serials.

PowerShellCrack avatar Nov 07 '24 14:11 PowerShellCrack