UNCLASSIFIED

Skip to content
Snippets Groups Projects
Commit 4e82f9c3 authored by Nicholas Yost's avatar Nicholas Yost
Browse files

Merge branch 'PS-Move-Activities-To-Public' into 'master'

Ps move activities to public for easier access by students and inclusion into private Field Guides

See merge request !5
parents 2418f1e1 b116c0e5
1 merge request!5Ps move activities to public for easier access by students and inclusion into private Field Guides
Pipeline #15112 passed with stage
in 10 seconds
Showing with 140 additions and 0 deletions
===== Activity: Add Two Numbers (1100-1115)
* Write a PowerShell script that prompts the user for two numbers, then outputs the two numbers with the math operator and the sum of the two numbers.
* Be able to explain your script in terms of variables and variable expansion.
.Sample
----
Enter Number One: 5
Enter Number Two: 10
5 + 10 = 15
----
===== Activity: Array Indexing and Math (1340-1410) Review to 1440
* Create file.txt on your desktop by running the following PS script:
[source,]
----
#This code will generate a file with the data for the exercise
[int]$i = $Null
do
{
$i ++
Add-Content C:\Users\$env:UserName\Desktop\file.txt $i
}
while ($i -lt 1000)
----
* Write a PowerShell script to do the following:
** Read file.txt on your desktop
** Extract the 135th(x), the 227th(y), the 578th(z) and the 892nd(n) numbers
** Add x and y and output the result
** Multiply x and z and output the result
** Subtract z from x and output the result
** Output (x + y) * (z – x) + (y + z)
** Output the (number of elements in the file) – (length of the nth element)
===== Activity: Conditional Processes (1000-1040)
Write a script that does the following:
* Queries the processes
* Selects a random process
* Outputs “Low process ID” if the process ID is less than 100
* Outputs the process name and session number if the process number is between 100 and 1000
* Checks if the process has more than 3 threads and prints the number of threads if the process id is 1000 or higher and has more than 3 threads
* Checks if the process has more than 5 handles and prints the number of handles if the process id is 1000 or higher and has more than 5 handles
===== Activity: Day of the Week
Write a PowerShell script that asks user for a date and returns the day of the week for that date
===== Activity: DNS Address Resolver
Write a PowerShell script that reads a file of fully qualified domain names, resolves their IP address with nslookup, parses the IP addresses and outputs a file with IP addresses nested under domain names.
===== Activity: Download Pictures from Website
* The cmdlet Invoke-WebRequest allows you to download files from the internet:
* Example: Invoke-WebRequest –URI https://technet.microsoft.com/en-us/scriptcenter/dd742419 -OutFile c:\powershell.html
* Write a script that does the following:
** Prompts a user for a webpage
** Downloads the webpage and saves it to a working file
** Looks though the webpage for all image references
** Downloads all the images and saves them in a subfolder
===== Activity: Exponents 1500 – End of Day
Write a script that does the following:
* Prompt the user for a base
* Prompt the user for an exponent
* Return the value (base)^(exponent)
===== Activity: Friendly Function
Write a PowerShell function with a parameter named time that takes an integer as input and a parameter names output that is a switch/flag parameter.
* The function should assess the time and return the following:
** 0600-1200: “Good morning”
** 1200-1700: “Good afternoon”
** 1700-2200: “Good evening”
** 2200-0600: “Good night”
* If no time is provided return: “Good day”
* If the output flag is set, the function should both return the string and print the output
===== Activity: Math Functions
Write six functions with the following names and purpose:
. add – takes two numbers and returns their sum
. subtract – takes two numbers and returns their difference
. multiply – takes two numbers and returns their product
. divide – takes two numbers and returns their quotient
. intdivide – takes two numbers and returns the integer quotient and the remainder (modulo arithmetic)
. exponent - takes two numbers and returns the base raised to the power
In your script test your four functions with basic arithmetic.
===== Activity: Ping List (1005-1040)
* Make a file with the following text:
** 8.8.8.8
** 8.8.4.4
** 214.48.80.29
* Write a script to read the file and ping each of the IP addresses in numerically ascending order.
===== Activity: Annoying Popups
* Write a PowerShell Script that opens 5 x instances each of Notepad, Firefox and Internet Explorer
* Every 30 seconds it kills all Notepad, Firefox and Internet Explorer and relaunches
* Every second it checks for cmd.exe and kills it
===== Activity: Processes 1 (1520 – End of Day)
Be able to explain the cmdlets used to accomplish all 3 steps:
* Step 1
** Open Notepad and Internet Explorer
** Query the processes
** Kill the processes from PowerShell
* Step 2
** Open Notepad and Internet Explorer
** Create a text document with the process names to kill
** Read the processes from the text document and kill the processes by name
* Step 3
** Query the processes and display only the following information in order by process ID
*** Process ID
*** Process Name
*** The time the process started
*** The amount of time the process has spent on the processor
*** The amount of memory assigned to the process
===== Activity: Processes 2 (1110-1355) Review to 1425
Create a PowerShell script and be able to explain the cmdlets used to achieve each step:
* Step 1
** Open Notepad and Internet Explorer
** In one line, query the processes, identify the notepad and internet explorer processes and kill them
* Step 2
** Open Notepad and Internet Explorer
** Write a script to:
*** Query the processes and identify the notepad and internet explorer processes
*** Save only the process ids to a file
*** Read the file and kill the processes by process id
* Step 3
** Query the processes and output the following on one line per process: Process Name – ID – Number of Threads
* Step 4 (Challenge)
** Query the processes and output the following
*** “Process Name – ID” for each process
*** List of thread IDs under each “Process Name – ID” line
===== Activity: Write a Basic PowerShell Script (1000-1015)
* Explore the PowerShell ISE and command line environment
* Write a PowerShell script that runs a few internal and external commands and saves the output to a file
* Run the PowerShell script from a PowerShell session and from the GUI (double click on script)
* Be able to trace your script and explain your output
===== Activity: Simple Calculator
* Write a PowerShell script that lists multiple available operations: addition, subtraction, multiplication, division, exponentiation and exit. The user selects a choice and the user is prompted for inputs for the functions. The script outputs the result. The process repeats until the user chooses exit.
* Extra: properly handle errors in data entry
===== Activity: Squares
Generate the squares of the numbers 1 to 100 and list the number and it's square.
Be sure to display the output in the following format: *1 squared is 1.*
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment