powershell switch statement

Hi Guys,

I am constructing a switch argument in powershell and how do I get the "lndapp01" on the name variable?


switch ($vm)
    {
        "LNDAPP01" {

$name=
$computerName = Get-WmiObject Win32_ComputerSystem
$computername.rename("$name")

}

thank you in advance,
Kelly GarciaSenior Systems AdministratorAsked:
Who is Participating?
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Correct. "If in doubt, check $_ out" ;-).
0
 
oBdACommented:
The usual "$_":
switch ($vm) { 
	"LNDAPP01" {
		$name = $_
		$computerName = Get-WmiObject Win32_ComputerSystem 
		$computername.rename($name)
	}
}

Open in new window

0
 
Kelly GarciaSenior Systems AdministratorAuthor Commented:
ohh ok thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.