First all I want to say hello to everybody. I am new here and I hope learn a lot of things with your experience and help. I am learning a little powershell because in my company we use it for some task and I think it is important for the future.
My questions in the following. I am making a simple code which I can query computers connected in our internal network in our domain and extract dell service tag (we work with dell computers). Sometimes, there are computers connected in the internal network but there are no members of our domain. One idea is use diferent combinations of localadministrator-password but sometimes dont work. We have not access to extract this info in the computers.
I would like to ask if there is one way for do this task. I would like to know the logic for trying to make a better code and learn a little more.
I don't think you'll have a nice clean "one way" to do this if you don't have access to the non-domain computers. Without some sort of access you can't do the required WMI queries to extract the service tag. A good read on remoting which should guide you on this issue can be found in the free ebooks section here https://powershell.org/newsletter/.
Agree with Matt on this one. What goal are you trying to accomplish if your getting serial number? Mostly likely want the warrnty information? While its not powershell. Free as in beer, there is a tool called spiceworks and you could turn on SNMP on the machines to assist you with warranty information. The latest version of spicework pull the warranty information for you in addition to some other nice features.