Question

Using PowerShell ISE or VSCode, create a PowerShell script that will do the following: Using functions,...

Using PowerShell ISE or VSCode, create a PowerShell script that will do the following:

  1. Using functions, create a loop to get data from user
    1. Name
    2. Address
    3. City
    4. State
    5. Zip
    6. Phone
  2. Store that data in a text file, appending to the end of the file
  3. Loop should have an option to quit before entering next set of data
  4. The file should
    1. Be in CSV format
    2. Have a header line

Homework Answers

Answer #1

$Path = "Enter Path Here!!"
Join-Path -Path $path -ChildPath "test.csv"

$counter = 1
$Header = "Name", "Address" , "City", "State", "Zip", "Phone Number"

$Header | foreach {Add-Content -Path $Path -Value $_}
while ($counter -ne 0){


$Name = Read-Host -Prompt 'Input Name: '
$Address = Read-Host -Prompt 'Input Address: '
$City = Read-Host -Prompt 'Input City: '
$State = Read-Host -Prompt 'Input State: '
$Zip = Read-Host -Prompt 'Input Zip Code: '
$Phone = Read-Host -Prompt 'Input Phone Number: '
$continue = Read-Host -Prompt "Do you want to continue? [Y/N]"
if ($continue -eq 'n' -or $continue -eq 'N'){
$counter = 0
}
$data = $name, $Address, $City, $State, $Zip, $Phone
$data | foreach {Add-Content -Path $path -Value $_ }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
A. Create a PowerShell script named “restore.ps1” within the “Requirements2” folder. For the first line, create...
A. Create a PowerShell script named “restore.ps1” within the “Requirements2” folder. For the first line, create a comment and include your first and last name along with your student ID. Note: The remainder of this task shall be completed within the same script file, “restore.ps1.” B. Write a single script within the “restore.ps1” file that performs all of the following functions without user interaction: 1. Create an Active Directory organizational unit (OU) named “finance.” 2. Import the financePersonnel.csv file (found...
Create a file consisting a group of 3 new user name’s and passwords in powershell, 1...
Create a file consisting a group of 3 new user name’s and passwords in powershell, 1 to a line. When you read in the line you’ll have to split the name and the password. a. Write a script in powershell that does the following i. Use get-content to retrieve the names and assign them to an array ii. Write a loop that prints out each of the user names. iii. Have your script create an account using localuser for each...
Name the script for.sh.  This script will create a shopping list. Ask the user to enter items...
Name the script for.sh.  This script will create a shopping list. Ask the user to enter items separated by a space. Read the list. Use a for loop to write (use echo) the items to a file called shopping_list. You should use >> to append the output to the file, so each time the script is run the list should get longer. After the for loop finishes, display (use cat) the contents of the shopping list with 1 item per line....
Subject: Shell Scripting Practice A File: practice-script-a Create File practice-script-a that: 1. Accepts any number of...
Subject: Shell Scripting Practice A File: practice-script-a Create File practice-script-a that: 1. Accepts any number of userids on the command line 2. For each userid, display the userid, PID, CPU time, and current command for each process owned by that userid Your output should look similar to this example: practice-script-a doug.jones User: doug.jones PID: 8748 TIME: 00:00:00 COMMAND: /usr/lib/systemd/systemd --user User: doug.jones PID: 8749 TIME: 00:00:00 COMMAND: (sd-pam)    User: doug.jones PID: 8750 TIME: 00:00:00 COMMAND: sshd: doug.jones@pts/5 User: doug.jones...
Write a script to create the following tables with attributes as specified(SQL) Customer table with Customer’s...
Write a script to create the following tables with attributes as specified(SQL) Customer table with Customer’s id, name, address, city as varchar, customer’s date of birth as date type and zip code number where the customers id is the primary key in the table, name and date of birth are mandatory. Id has a 10-character limit, name, address and city have a 50-character limit, zip has a 5-character limit Product Table with Product id, description and finish as varchar, price...
Create a program that filters the data in a CSV file of product data based on...
Create a program that filters the data in a CSV file of product data based on some search word and prints the resulting output to a new file. Additionally, the program will print the number of items filtered to stdout. • Your program should take three arguments: an input file to process, an output file to save the results, and a search word. • If the output file already exists or cannot be opened, warn the user by printing "CANNOT...
1) Create one php file with the 4 parts. Each part should do the following: The...
1) Create one php file with the 4 parts. Each part should do the following: The 1st part of the script implements a while loop that displays odd numbers between 1 and 15. The 2nd part of the script implements a for loop to display numbers between 10 and 20 The 3rd  part of the script includes the following variable declaration: $sales = 5000; Using if/elseif/else statement determine the bonus percent. Make sure to change the value of $sales to fully...
For this assignment, create an html page that has a login form. The form should have...
For this assignment, create an html page that has a login form. The form should have 3 input elements -- 1. This should have a type text for the user to enter UserName 2. This should have a type password (like text except cannot see the text that is typed in), for the user to enter password. 3. Submit button (type submit, as we did in class on 2/6). The form method should be set to POST and the action...
I am looking for PYTHON code that will display the following: Code a menu-driven application that...
I am looking for PYTHON code that will display the following: Code a menu-driven application that does the following: The user can enter data for a product name, product code, and unit price. An example might be 'Breaburn Apples', 'BAP'. 1.99. After entering the data, it is appended (note I said 'appended') as a single line of text to a text file. Each line of text in the file should represent a single product. There is an option to display...
This program is in C++: Write a program to allow the user to: 1. Create two...
This program is in C++: Write a program to allow the user to: 1. Create two classes. Employee and Departments. The Department class will have: DepartmentID, Departmentname, DepartmentHeadName. The Employee class will have employeeID, emploeename, employeesalary, employeeage, employeeDepartmentID. Both of the above classes should have appropriate constructors, accessor methods. 2. Create two arrays . One for Employee with the size 5 and another one for Department with the size 3. Your program should display a menu for the user to...