Skip to content

OSDComputerName or other variables for setting computer name

Featured Replies

We are working on deploying Server 2012 R2 via SCCM with Roles being installed based on the computer name.

Our computer naming standards are "location-role-number" where the role is a 2 letter variable like WB for web server.

 

In our task sequence we have added the following condition on the IIS role install...

If ALL conditions are true:

Task Sequence Variable OSDComputerName greater than or equals "%wb%.

 

what we are seeing is that the IIS role will install on any server no matter what the name is. so clearly there's something wrong in the logic of the variable.

 

Any help is greatly appreciated.

 

Scott

I don't believe that a task sequence will support a partially matching variable. In order to use '%wb%", the condition would have to be Variable OSDComputerName like "%wb%" which doesn't exist in TS.

  • Author

Thanks. That backs up what I was suspecting.

 

Any other options you can think of for using a variable for the name to install the different roles on different servers?

 

I would like to keep this to just one task sequence if possible and use variables for the different types of server roles that our company uses.

 

Thanks for your help.

Scott

Why not use a PowerShell script to check the computer name and install the necessary roles using that? The local computer name can be retrieved using $env:computername and you can install roles and features with something like this:

 

Install-WindowsFeature –Name Web-Server -ComputerName LocalComputerName (this would be your local computer name or PS variable you assigned to the $env:computername)

  • Author

Thanks for the suggestion. Now to try to find someone on my team who knows PowerShell. I'm a bit of a noob when it comes to scripting. :D

Just set up a collection based on "%wb%" and deploy the PowerShell to that collection - so have a PowerShell script that looks like this:

 

Install-WindowsFeature -Name Web-Server -IncludeAllSubFeature -ComputerName Server1

 

Just add what feature you need and if you don't need all sub features, then don't include the -IncludeAllSubFeature.

 

If you would like more of an explanation let me know in a PM.

Not sure of your Asset design, but you could create collections based on roles... for example you could have collections like so:

  • IIS servers
  • Print servers
  • DHCP servers

and so on.

If your systems are bare metal systems you could use the import computer configuration method and specify which collection to add them to.

 

At the collection level you could create collection variables for example:

  • The IIS server collection have a collection variable like InstallWebServerRole and set to True
  • The Print server collection have a collection variable like InstallPrintManagement and set to true

and so on.

 

Then in your Task sequence create groups and at the root of each group put a task sequence variable to match that of the collection variable.

So for example if you create a group in your TS called deploy IIS role and below this the steps you need to actually configure this role and on the root (the group folder itself) you add a task sequence variable of InstallWebServerRole and set to true also then when you deploy this task sequence out to this collection it will check against the conditions and see that the imported system is indeed a member of IIS servers collection and the conditions set match each other so the IIS role will get installed on this system.

 

 

The beauty about this will be that all the groups (roles to be installed) can be attached to the one TS and the collection and task sequence variables look after what gets installed.

There is of course probably a more automated way of achieving what you are looking for, but if you don't mind importing bare metal systems into the desired collections then this should work a treat and give you the outcome you are looking for.

 

TBH not sure if trying it the Computer Name will actually work as I think that SCCM still thinks that the systems been OSD'd is still the generic name of MININTxxxxx right up until the end of the deployment, by which at this time in the deployment it is too late!

This is of course in bare metal deployments anyway!

  • Author

Thanks for the replies.

 

We ended up going with a the following WMI Query to get the computer name.

 

SELECT * from win32_ComputerSystem where Name like "%WB%"

 

Once we added this to the options for the item it works as expected.

 

Scott

Join the conversation

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

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.