Jump to content

Help with PowerShell script

Go to solution Solved by Guest,

A loop is what you think of?

so something like

 

while (($input = write-host "Input selection") -eq 1) -and ($input = write-host "Input selection") -eq 2)
{
  if ($input -eq 1)
  {
  #write-host sarah and everything relevant to him/her
  }
  elseif ($input -eq 2)
  {
  #write-host shaun and everything relevant to him/her
  }
}

 

OK so I've been working on learning PowerShell and as it's Daddy weekend I decided to show my kids some fun things that you can do with PowerShell and naturally it didn't work... Lol

What I'm trying to do seems like it would be pretty basic but I'm either making it too difficult or missing something. Lol

 

The goal is to have a script or text file that I can enter my children's information in to like this:

#Daughter's Information

$daughterInfo = @(

$firstName = "Sarah"

$lastName = "Marshall"

$birthday = "October 12th, 2006"

$gender = "Her"

)

 

#Son's Information

$sonInfo = @ (

$firstName = "Shaun"

$lastName = "Marshall"

$birthday = "January 30th, 2010"

$gender = "His"

)

 

On the second script I would like to write-Host and then write out a bunch of text that will list all the information from the first script but I want to just be able to change one thing so that it pulls information from the correct area.

[In PowerShell]

Please Select a Child

1. Sarah

2. Shaun

[Here you would choose a child, Let's say I chose Shaun]

 

Write-Host "This is some information about $sonInfo.FirstName"

Write-Host "Full Name - $sonInfo.firstName $sonInfo.LastName"

Write-Host "$sonInfo.gender birthday is $sonInfo.birthday"

 

[PowerShell Output]

This is some information about Shaun

Full Name - Shaun Marshall

His birthday is January 30th, 2010

 

So obviously I want it to list out more than that but if someone can show me the basic way I should be able to figure out the rest (hopefully) Lol

I did Google but I wasn't sure exactly how to word the search...

Thanks,

Ryan

Link to comment
https://linustechtips.com/topic/785663-help-with-powershell-script/
Share on other sites

Link to post
Share on other sites

A loop is what you think of?

so something like

 

while (($input = write-host "Input selection") -eq 1) -and ($input = write-host "Input selection") -eq 2)
{
  if ($input -eq 1)
  {
  #write-host sarah and everything relevant to him/her
  }
  elseif ($input -eq 2)
  {
  #write-host shaun and everything relevant to him/her
  }
}

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×