Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

powershell switch statement

Posted on 2014-04-16
3
376 Views
Last Modified: 2014-04-16
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,
0
Comment
Question by:Kay
3 Comments
 
LVL 84

Assisted Solution

by:oBdA
oBdA earned 250 total points
ID: 40003713
The usual "$_":
switch ($vm) { 
	"LNDAPP01" {
		$name = $_
		$computerName = Get-WmiObject Win32_ComputerSystem 
		$computername.rename($name)
	}
}

Open in new window

0
 
LVL 69

Accepted Solution

by:
Qlemo earned 250 total points
ID: 40004002
Correct. "If in doubt, check $_ out" ;-).
0
 

Author Comment

by:Kay
ID: 40004161
ohh ok thanks
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question