What exactly are you trying to achieve here?
A simple Get-WMIObject and a couple of Read-Hosts should do what you need it to:
$className = Read-Host "Enter Class Name"
$computerName = Read-Host "Enter Computer Name"
if ([string]::IsNullOrWhitespace($computerName)) {
$computerName = "."
}
Get-WmiObject -ComputerName $computerName -Class $className
Bolt in a bit of extra error checking so that you aren't trying to check an invalid class name etc and you should be good to go. Example below:
You can also contatenate inside a command strings like so:
Get-WMIObject -Class ($string1 + "32" + "_" + $string2) -ComputerName "."
(in this case, $string1 contains "WIN" and $string2 contains "BIOS")
Things in brackets are processed before it's parent command. You can even go deeper and do brackets within brackets.. PowerShell will start at the deepest level and work it's way out until it hits the parent command and then execute the fully computed strings.
1
You should provide a sample of what you're hoping to use/do and why it's not working. Additionally, always search and see if existing articles out there explain how to do things, for instance this first google result: https://technet.microsoft.com/en-us/library/ee176860.aspx
– Abraxas – 2016-02-22T16:48:59.003$obj=Get-WmiObject -class "class1" -namespace "space1" $obj| Invoke-wmiMethod -name fun -ArgumentList $devUUID , $role , $status – Shantanu Kumar – 2016-02-22T16:58:52.213
and there is no need of complter name because i am working on current host – Shantanu Kumar – 2016-02-22T17:01:10.073
$obj=Get-WmiObject -class "class1" -namespace "space1"
$obj| Invoke-wmiMethod -name fun -ArgumentList $devUUID , $role , $status – Shantanu Kumar – 2016-02-22T17:59:45.737
You have an example, but it isn't clear what this is or how it relates. Is it sample code you found somewhere? If this what you're trying to use and it isn't giving you what you want? If so, what result do you want, what does this code give you, and how is the result not satisfactory? – fixer1234 – 2016-02-25T06:33:27.677