Question

In: Computer Science

Write a PowerShell script that will ask your name, Date of Birth (DOB). Print a message...

Write a PowerShell script that will ask your name, Date of Birth (DOB). Print a message on console with a message like the examples. a. If the DOB you entered is in the future, print “Hello XXXXX, there are XXX days to your Birthday!” b. If the DOB you entered is today, print “Hello XXXXX, happy birthday!” c. If the DOB you entered is in the past, print “Hello XXXXX, your next birthday will be in XXX days.” d. Replace the XXXXX with the user input. XXX must be calculated.

Solutions

Expert Solution

Below is the solution:

$Name = Read-Host "Please enter your name" #read name
$DOB = Read-Host "Enter date of birth" #read dob 10/20/2020
$NumberOfDays=(New-TimeSpan -End $DOB).Days #fins the days

if ($NumberOfDays -eq 0) { #check days is 0
    Write-Host "Hello " $Name", happy birthday!" #print happy birthday
}
elseif ($NumberOfDays -gt 0){ #check days is > 0
    Write-Host “Hello"$Name ", there are " $NumberOfDays " days to your Birthday!” #print days left birthday
}
elseif ($NumberOfDays -lt 0){ #check days is < 0
    Write-Host "Hello " $Name ", Your next birthday will be in " (365-(-($NumberOfDays))) "days" #print days to birthday
}

sample output:


Related Solutions

Write Powershell Script Verifies System Environment Variable Lmlicensefile Exists Exists S Q42980878 write a PowerShell script...
Write Powershell Script Verifies System Environment Variable Lmlicensefile Exists Exists S Q42980878 write a PowerShell script that verifies the 'System' environmentvariable, 'LM_LICENSE_FILE', exists. If it exists, the scriptshould also verify that the variable [email protected] (which represents the port and server theLM points to) as one of the values in the variable. Values (if anyare present) are separated by commas "," in this variable. Finally,if the value does not exist, this script should also performremediation (add the desired value to the...
Windows PowerShell 1) Write a PowerShell Script to monitor a file for changes. 2) Write a...
Windows PowerShell 1) Write a PowerShell Script to monitor a file for changes. 2) Write a PowerShell Script to create a user account in a specific OU.
Task 2.5: Write a script that will ask the user for to input a file name...
Task 2.5: Write a script that will ask the user for to input a file name and then create the file and echo to the screen that the file name inputted had been created 1. Open a new file script creafile.sh using vi editor # vi creafile.sh 2. Type the following lines #!/bin/bash echo ‘enter a file name: ‘ read FILENAME touch $FILENAME echo “$FILENAME has been created” 3. Add the execute permission 4. Run the script #./creafile.sh 5. Enter...
Requirements1. Name the java class (and filename) Week3_StringLab .2. Print a welcoming message. 3. Ask user...
Requirements1. Name the java class (and filename) Week3_StringLab .2. Print a welcoming message. 3. Ask user to enter a string. Use the nextLine() input method, 4. Use that string to test out at least 6 String methods, from the String class. 5. Of those 6, you must use these 3 methods: .split(), .indexOf (int ch), .subString (int beginningIndex). 6. Use 3+ other methods that you wish to try. 7. Print out the string BEFORE using each method .8. Have the...
Write an assembly language program that will print out the message of your choosing #NOTE #write...
Write an assembly language program that will print out the message of your choosing #NOTE #write in a simple way, so that i can execute it from command window using masm
Write a PowerShell script which will prompt user to enter the number of the day of...
Write a PowerShell script which will prompt user to enter the number of the day of the week (e.g. 1,2,3,4,5,6,7) and return the day of the week. (e.g. Sunday...etc.) (Hint: Sunday is the 1st day of the week).
Script 3: Ask the user for a file's name If the file exists, ask them if...
Script 3: Ask the user for a file's name If the file exists, ask them if they would like to (C)opy, (M)ove, or (D)elete it by choosing C, M, or D If the user chooses C, ask for the destination directory and move it there If the user chooses M, ask for the destination directory and move it there If the user chooses D, delete the file. Ensure that the user enters only C, M, or D, warning them about...
Write a bash script that will allow you to: Read in your Your name Course name...
Write a bash script that will allow you to: Read in your Your name Course name and Instructor’s name Then prompt the user to enter two numbers and determine which number is greater. Ex: If 10 is entered for the first number and 3 for the second, you should output Your name Course name Instructor’s name 10 is greater than 3. If 33 is entered for the first number and 100 for the second, you shou output Your name Course...
Write a Powershell script to create a Windows user account that is a non-admin user. This...
Write a Powershell script to create a Windows user account that is a non-admin user. This assignment assumes that you already have a Windows VM, with the administrator account created.. To complete the assignment, write the PowerShell script, run it on your VM, and submit the script here.
Use your webcam and record a movie, write a motion detection code and print the message...
Use your webcam and record a movie, write a motion detection code and print the message "Motion Detected" on the original frame. Try to make a better visualization by using different masking. ---using Numpy and opencv
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT