Question

POWERSHELL: Create a hash table with the following fields containing appropriate values: (1) Product name Price...

POWERSHELL:

Create a hash table with the following fields containing appropriate values: (1)

  1. Product name
  2. Price
  3. Expiry date (use the current date and time)

Using the hash table you created in the previous question, write an if statement that tests whether or not the product in question has expired or not. Use the current date and time as the reference point. (2)

Change the date in the hash table to a different (probably future) date and run your if statement second time to get a different result.

Homework Answers

Answer #1

1) Solution

Checking whether the product has expired or not by comparing today's date with product's expiry date which is also today's date only.

$hash = @{ product_name = "biscuit"; price = 50; expiry_date = Get-Date }
$date = Get-Date
if($hash["expiry_date"] -gt $date)
{
write-host("The product has not expired")
}
else
{
write-host("The product has expired")
}

2) Solution second

Changing the expiry date to some future date and comparing with today's date

$hash = @{ product_name = "biscuit"; price = 50; expiry_date = Get-Date "2020-11-30"}
$date = Get-Date
if($hash["expiry_date"] -gt $date)
{
write-host("The product has not expired")
}
else
{
write-host("The product has expired")
}

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
Use the Donor database attached to the assignment answer the following: Question 1: Create a block...
Use the Donor database attached to the assignment answer the following: Question 1: Create a block to retrieve and display pledge and payment information for a specific donor. For each pledge payment from the donor, display the pledge ID, pledge amount, number of monthly payments, payment date, and payment amount. The list should be sorted by pledge ID and then by payment date. For the first payment made for each pledge, display “first payment” on that output row. 2 marks...
Database Management and Design Homework assignment Directions: Create an ERD for the following case. Make sure...
Database Management and Design Homework assignment Directions: Create an ERD for the following case. Make sure you use the proper cardinalities. Sweeping Bulldog (SB) is an online textbook exchange portal. It allows an individual or customer (student, faculty, staff, etc.) to sell their used textbooks directly to other people without going through the formal UTC book store. The portal allows the individual to drop off their books anytime, most probably at the end of one semester. The individual then receives...
QUESTION 1 Which of the following best exemplifies offshoring? A. A U.S. company employs foreign nationals...
QUESTION 1 Which of the following best exemplifies offshoring? A. A U.S. company employs foreign nationals at its U.S. based headquarters. B. A U.S. company translates novels originally written in foreign languages into English for distribution in the U.S. market. C. A U.S. company starts a chain of fusion restaurants to cater to the American public’s evolving palates. D. A U.S. company purchases footwear made in Europe to distribute to retailers in the United States. E. A U.S. company that...
Question 1 of 15 Linsay’s Landscaping wants to make notes in QuickBooks each time she services...
Question 1 of 15 Linsay’s Landscaping wants to make notes in QuickBooks each time she services a client to streamline the invoicing process at the end of the month. She does not want these records to affect any month or year to date financial reports throughout the month until she invoices the client. Which of the following transaction types do you recommend she uses to achieve this goal? A. Invoice B. Credit Memo C. Sales Receipt D. Delayed Charge E....
Question 1 of 15 Which of the following is not a recommended starting point to enter...
Question 1 of 15 Which of the following is not a recommended starting point to enter sales of products/services? A. Quick Create > Invoice B. Register > New transaction C. Quick Create > Sales Receipt D. Customer detail page > New transaction E. Transactions > Sales > New transaction Question 2 of 15 Which of the following statements accurately describes bank rules? A. Bank rules are imported from the Bank's website into the For Review tab in the Banking Center...
1. By convention, how are configuration files separated from regular files? (NOTE: A practical effect of...
1. By convention, how are configuration files separated from regular files? (NOTE: A practical effect of the separation is that they are not displayed by the default version of the ls command)                         a. the prefix "rc" (rc.filename)               c. the extension .cfig                         b. a dot (.) at the beginning                    d. by having the SUID bit set 2. The IP address which is reserved for local loopback (equivalent to "localhost") is:                         a. 255.255.255.0                                   c. 192.168.70.1...
1. Read the following instructions on 'How to Repair an Electric Fan' which are written in...
1. Read the following instructions on 'How to Repair an Electric Fan' which are written in three different parts before answering the question given. The instructions below are considered ineffective as they are not following the effective instructions strategy. 1 Turn your fan on to make sure that the motor works. Plug your fan in and turn it on to the highest power setting. If the fan blades move a little or it starts to turn, the motor is probably...
/* myCompany.SQL Introduction to SQL Script file for ORACLE DBMS This script file creates the following...
/* myCompany.SQL Introduction to SQL Script file for ORACLE DBMS This script file creates the following tables: VENDOR, PRODUCT, CUSTOMER, INVOICE, LINE EMPLOYEE and loads the default data rows */ set echo on; set serveroutput on; select systimestamp from dual; show user; ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY'; DROP TABLE LINE CASCADE CONSTRAINTS; DROP TABLE INVOICE CASCADE CONSTRAINTS; DROP TABLE CUSTOMER CASCADE CONSTRAINTS; DROP TABLE PRODUCT CASCADE CONSTRAINTS; DROP TABLE VENDOR CASCADE CONSTRAINTS; DROP TABLE EMPLOYEE CASCADE CONSTRAINTS; CREATE TABLE...
In February 2012, the Pepsi Next product was launched into the US market. This case study...
In February 2012, the Pepsi Next product was launched into the US market. This case study provides students with an interesting insight into PepsiCo’s new product process and some of the challenging decisions that they faced along the way. Pepsi Next Case Study Introduction Pepsi Next was launched by PepsiCo into the US market in February 2012, and has since been rolled out to various international markets (for instance, it was launched in Australia in September 2012). The new product...
ECO 101-S70: Final Quiz 2 CHAPTER 3: Demand, Supply and Equilibrium 1. Which of the following...
ECO 101-S70: Final Quiz 2 CHAPTER 3: Demand, Supply and Equilibrium 1. Which of the following could cause a decrease in consumer demand for product X? a.   a decrease in consumer income b.   an increase in the prices of goods which are good substitutes for product X c. an increase in the price which consumers expect will prevail for product X in the future d. a decrease in the supply of product X 2. If two goods are substitutes for...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT