PowerShell to Create teh computer name

So I have been avoiding to learn PowerShell like an idiot and I really need to lear.

so, what Im trying to do is simple for some of you… lol

Im trying to generate a script that will give me a single string with the computer name for SCCM.

this will contain.

[location]-[System Type]-[Serial Number]

so I’m trying to organize the idea.


Identifying the laptop: Most people use the old trick… does it have a battery? the problem is that sometimes the team ends up imaging a system with no battery for X or Y reason and that comes up as a Desktop.

So I found this instead.

Get-WmiObject -Class win32computersystemproduct | select-object version)

This is good for us Since our systems are Lenovo.


I’m getting 2 values Thinkpad and then T460p

I only want to base the query on is Thinkpad or ThinkStation or ThinkCenter

Then if is a Thinkpad give me an L

[Location]-L-[Serial Number]

for now this is all I want to do. There is ofcurse more but I would hate one of you with your good heart to do it for me and I want to lear to do it my self, not to get it done.

Thank you in advanced.

submitted by /u/nikolasmantilla
[link] [comments]

Leave a Reply