Question

Write a PowerShell script. Make sure to: Comment your script by including your name, date, and...

Write a PowerShell script. Make sure to:

  1. Comment your script by including your name, date, and short description what the script does
  2. The script receives two arguments/parameters, first one should be a string and the second one an integer number. Both should be passed to the script as (positional) arguments/parameters
    1. Check if there are two passed parameters
    2. Check if passed parameters are as expected (check if first is string and secondis integer). You can use param() here.
    3. Displays on the screen both of these arguments with a text explaining them and the type of each of them (e.g., “The first received parameter is: … and its type is ….”).
    4. Display the first argument as the string in upper case letters only
    5. Display the length of both arguments (also with some informative text on what are you displaying). Note that you will have to convert the second argument, which is an integer, to a string to complete this step
  3. The script includes a function that:
    1. Displays all the processes with -ProcessName comprising string “win” ordered by their IDs
    2. Call the function defined as an answer to 3.a. from within your script
  4. Use piping to list and stop all not-responding processes

THE SCRIPT SHOULD BE WELL COMMENTED!!!!!

0 0
Add a comment Improve this question Transcribed image text
Answer #1


Save the following code in "filename.ps1"

#[DEBUG]defining a function to display all non-responding processes

function Display_Non_responding_process{

#[DEBUG]inside function"

Get-Process -ErrorAction SilentlyCOntinue | Sort-Object -Property Id | Format-Table

}

#[DEBUG]Printing first Argument and its type

Write-Host "First Argument received is =" $Args[0] " and Type is " $Args[0].getType()

#[DEBUG]Printing second Argument and its type

Write-Host "Second Argument received is =" $Args[1] " and Type is " $Args[1].getType()

#[DEBUG]Printing second Argument in lower case

Write-Host "Displaying Second argument in lower case: " $Args[1].ToLower()

#[DEBUG]Printing Argument Character length

Write-Host "Total character length of Arguments =" ([string]$Args).length

Display_Non_responding_process

Add a comment
Know the answer?
Add Answer to:
Write a PowerShell script. Make sure to: Comment your script by including your name, date, and...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Problem 1 Write a BASH script to create a user account from the Linux system on...

    Problem 1 Write a BASH script to create a user account from the Linux system on which your script is run. The script should process two positional parameters. First positional parameter is supposed to be a string with a user name (e.g., user_name) Second positional parameter is supposed to be a string with a user password (e.g., user_password) In your script: Check if two positional parameters were passed to your script when it was invoked If NOT, print an appropriate...

  •  Write a Perl script that accepts exactly 2 integer arguments where the first argument must...

     Write a Perl script that accepts exactly 2 integer arguments where the first argument must be less than the second argument. The script will print a comma separated list of integers starting with the first argument up through the second argument.  The last printed value should be the second command line argument not be followed by a comma.  The script should also be able to handle the following errorsituations: o incorrect number of arguments o the first...

  • We are trying to make sure your passphrase is acceptable! Write a script that asks for...

    We are trying to make sure your passphrase is acceptable! Write a script that asks for an input string that will be used as your password. This input string will have three “words” separated by a space character. Each of these words has specific requirements, listed below. You must write a function for each requirement (three total functions). Make sure your functions follow the original template that provided. First Function: For the first word, you must check if it is...

  • Create a Python script file called hw12.py. Add your name at the top as a comment,...

    Create a Python script file called hw12.py. Add your name at the top as a comment, along with the class name and date. Ex. 1. a. Texting Shortcuts When people are texting, they use shortcuts for faster typing. Consider the following list of shortcuts: For example, the sentence "see you before class" can be written as "c u b4 class". To encode a text using these shortcuts, we need to perform a replace of the text on the left with...

  • Need help writing beginner C# program, I will make sure to provide feedback to whoever can...

    Need help writing beginner C# program, I will make sure to provide feedback to whoever can help me figure it out! No public or global variables should be used. You need to consider passing arguments between the methods according to the ways described in the lecture. i.e. all variables should be declared inside the methods and passed to other methods by value/ref/out as needed Description: We want to design a Date class to represent a date using three integer numbers...

  • Please write this code in python programming and provide a screen short of the code. Reading:...

    Please write this code in python programming and provide a screen short of the code. Reading: P4E 7; Tut 7.2, 7.2.1 Upload an original Python script that satisfies the following criteria: It has at least two functions Function 1: This function has one parameter, a string containing the path to an existing text file that will be read by your function Using a with statement, the function opens the file indicated by the parameter for reading The function counts the...

  • Write a python program (recursive.py) that contains a main() function. The main() should test the following...

    Write a python program (recursive.py) that contains a main() function. The main() should test the following functions by calling each one with several different values. Here are the functions: 1) rprint - Recursive Printing: Design a recursive function that accepts an integer argument, n, and prints the numbers 1 up through n. 2) rmult - Recursive Multiplication: Design a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times...

  • C++ implement and use the methods for a class called Seller that represents information about a...

    C++ implement and use the methods for a class called Seller that represents information about a salesperson. The Seller class Use the following class definition: class Seller { public: Seller(); Seller( const char [], const char[], const char [], double ); void print(); void setFirstName( const char [] ); void setLastName( const char [] ); void setID( const char [] ); void setSalesTotal( double ); double getSalesTotal(); private: char firstName[20]; char lastName[30]; char ID[7]; double salesTotal; }; Data Members The...

  • //Done in C please! //Any help appreciated! Write two programs to write and read from file...

    //Done in C please! //Any help appreciated! Write two programs to write and read from file the age and first and last names of people. The programs should work as follows: 1. The first program reads strings containing first and last names and saves them in a text file (this should be done with the fprintf function). The program should take the name of the file as a command line argument. The loop ends when the user enters 0, the...

  • The first script is validate.sh. This is a simple form validation script that will be used...

    The first script is validate.sh. This is a simple form validation script that will be used to verify the inputs given. Normally, this would be done to validate input from a website or another program before entry into a database or other record storage. In this case, we will keep it simple and only focus on the input validation step. In particular, the script should prompt the user for four values: first name, last name, zip code, and email address....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT