Jump to content


Need to rename PC during OSD

Recommended Posts

Hi all, I need some help and it might be something easy. I have no scripting skills and tried various methods on the internet but it's not working.

All I want is for the TS to ask me what computer name I want for the deployment, some sort of popup.

Share this post

Link to post
Share on other sites

I have the following in a PS script but the TS fails.

[string] $MacAddress = Get-WmiObject Win32_networkadapterconfiguration | where {$_.ipenabled -match "True"} | select -ExpandProperty MacAddress | select -First 1
[string[]]$TextFiles = Get-Content \\fileshare\*.txt
foreach ($element in $TextFiles){
[string[]]$TextFilesSplit = $element.Split("=")
[string]$MacFromArray = $TextFilesSplit[0]
[string]$ComputerNameFromArray = $TextFilesSplit[1]
$MacFromArray = $MacFromArray.Trim(" ")
$ComputerNameFromArray = $ComputerNameFromArray.Trim(" ")
if($MacAddress -eq $MacFromArray){
$OSDComputerName = $ComputerNamefromArray
$TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment 
$TSEnv.Value("OSDComputerName") = "$OSDComputerName"


This is what the log file says

Running powershell script: 'OSDComputerName.ps1'(PkgID: BFM000E5) with execution policy: 'Bypass'    RunPowerShellScript    2019-08-23 09:11:47    2788 (0x0AE4)
Filesystem::File::Exists( sPowerShellPath.c_str() ) == true, HRESULT=80070490 (main.cpp,345)    RunPowerShellScript    2019-08-23 09:11:47    2788 (0x0AE4)
PowerShell.exe does not exist at 'X:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe'    RunPowerShellScript    2019-08-23 09:11:47    2788 (0x0AE4)
ExecutePowerShellScript(sScriptName, sParameters, sPackageID, sExecutionPolicy, sOutputVariableName, dwPSRunExitCode), HRESULT=80070490 (main.cpp,876)    RunPowerShellScript    2019-08-23 09:11:47    2788 (0x0AE4)
Run PowerShell script failed to run, hr=0x80070490    RunPowerShellScript    2019-08-23 09:11:47    2788 (0x0AE4)
Process completed with exit code 2147943568    TSManager    2019-08-23 09:11:47    1040 (0x0410)

And I'm trying to run it like the attached.

Untitled picture.png

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...