Asked by:
Will powershell script for assign computer name on the basis of serial number and model work on vmware machine ?

Question
-
Hi All,
I was following an article :https://msendpointmgr.com/2013/06/03/automate-computer-name-during-osd-in-configmgr-2012-with-powershell/
to assign the computer name using powershell using s/n and model but i was testing it on vmware machine .
I am getting error on "Set PowerShell Execution Policy."for this i used command line as per the blog i.e :
powershell.exe -noprofile -command "Set-ExecutionPolicy Bypass LocalMachine" -force
i did same as per the above page what could be reason for this failure ?
Friday, July 31, 2020 7:41 AM
All replies
-
-
https://easyupload.io/dqh4n6
i am getting now the screenshot attached error . powershell component is added in to the boot files and now i am getting error when the script is executed. i am running it in vmware machine.
Sunday, August 2, 2020 2:06 PM -
some one will help in this ?Sunday, August 2, 2020 2:07 PM
-
hmmm no one with any suggestionMonday, August 3, 2020 3:54 AM
-
Hi,
Thanks for posting in TechNet.
If possible, please help try to change the command lines in your reference article:
1.Remove below command line in step 3:
powershell.exe -noprofile -command "Set-ExecutionPolicy Bypass LocalMachine" -force
2.Then change the command line in step 4,
from: powershell.exe -noprofile -file OSDComputerName.ps1
to: powershell.exe -noprofile -ExecutionPolicy Bypass -file OSDComputerName.ps1
Thanks for your time.
Best regards,
SimonPlease remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.Monday, August 3, 2020 7:28 AM -
any 1 o_0Monday, August 3, 2020 8:47 AM
-
I am using script :
$ComputerModel = (Get-WmiObject -Class Win32_ComputerSystem | Select-Object Model).Model $SerialNumber = (Get-WmiObject -Class Win32_BIOS | Select-Object SerialNumber).SerialNumber # Workstations if (($ComputerModel -match "Precision") -OR ($ComputerModel -match "Optiplex")) { $OSDComputerName = $SerialNumber + "-" + "WS" $TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment $TSEnv.Value("OSDComputerName") = "$OSDComputerName" } # Laptops if ($ComputerModel -match "Latitude") { $OSDComputerName = $SerialNumber + "-" + "LAP" $TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment $TSEnv.Value("OSDComputerName") = "$OSDComputerName" }
It is correct script for vmware machine ????
Monday, August 3, 2020 8:54 AM -
Some 1 with any help ?Tuesday, August 4, 2020 1:22 PM
-
Hi,
Could the hostname length be the culprit? According to below article, the maximum hostname length is 15 characters, and the host name has a restriction on some special characters, such as white space (blank). VMWare VMs have very long serial numbers that contain spaces.
Naming conventions in Active Directory for computers, domains, sites, and OUs
Dynamically Set Hostname in SCCM Task Sequence
Thanks for your time!
Best regards,
SimonPlease remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.Wednesday, August 5, 2020 8:56 AM