Вы находитесь на странице: 1из 2

UEE40111 Certificate IV in Computer Systems

Net Admin Fundamentals 2


Units: ICANWK403A, ICANWK402A, UEENEED104A, ICANWK409A

336108412
1) PowerShell Tutorials
a. Start a ServerA (or another Windows Server 2012 R2 virtual machine that is a domain
controller it probably doesnt matter for earlier exercises, but it will later). You may want to
install guest additions so that you can cut and paste to your VM.
b. Signon as Superman
c. Run Windows PowerShell ISE
or
You could use just the PowerShell command line, plus an editor like notepad++, note if your
scripts are not local then also run: set-executionpolicy unrestricted
d. Open the web page http://www.powershellpro.com/powershell-tutorial-introduction/
e. Work through tutorials
i. 7 http://www.powershellpro.com/powershell-tutorial-introduction/variables-arrayshashes/
ii. 8 http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorialconditional-logic/
iii. 9 http://www.powershellpro.com/powershell-tutorial-introduction/logic-using-loops/
2) Enter the following commands into your PowerShell session (the following questions will use the
variables/objects created).
$a = Merry
$b = Christmas
$me = Bill
$you = Guru
$names = @(Barry, Harry, Larry, Benny, Penny, Lenny)
$n1 = 4.0
$n2 = 3.0
$n3 = 0.5
$numbers1 = @(1.5, 2.5, 3.5, 4.5)
$numbers2 = @(10.5, 21.5, 23.5, 4.5)
$sentence1 = The quick brown fox jumps over the lazy dog
$sentence2 = That was then, this is now
3) Write and paste here a piece of code that:
Uses the concatenation operator to compose a greeting message that includes arbitrary text, $you
and $me.
PS C:\Users\Administrator> Hello + $you + and + $me
4) Write and paste here a piece of code that:
Uses interpolation to compose a greeting message that includes arbitrary text, $you and $me.
PS C:\Users\Administrator> Hello $you And $me
5) Write and paste here a piece of code that:
Calculates the length of $sentence1
PS C:\Users\Administrator> $sentence1.length
6) Write and paste here a piece of code that:
Uses the replace method to create a new string from $sentence2, replacing th with f.
PS C:\Users\Administrator> $sentence3 = $sentence2 replace th,f
7) Write and paste here a piece of code that:
Prints whether or not $n2 is greater than $n1
PS C:\Users\Administrator> $n2 gt $n1
8) Write and paste here a piece of code that:
Prints the largest out of $n2 and $n1. Hint: use the if statement.
PS C:\Users\Administrator> $x = 3.5
If (
$x lt $n1
) {write-host $n1}
Else {write-host your argument is not valid}
9) Write and paste here a piece of code that:
Uses at least 4 arithmetic operators and the variables $n1, $n2 and $n3 to calculate a value.
4 * ($n1 + $n2) / $n3

Page 1 of 2

UEE40111 Certificate IV in Computer Systems


Net Admin Fundamentals 2
Units: ICANWK403A, ICANWK402A, UEENEED104A, ICANWK409A

336108412
10) Write and paste here a piece of code that:
Uses the for each command to print out a greeting to each of the names in the array $names
Foreach ($name in $names){write Hello $name
11) Write and paste here a piece of code that:
Prints out a greeting only to the names in the array $names that end in arry.
foreach ( $name in $names){if ($name like *arry){write "Hello $name"}}
12) Write and paste here a piece of code that:
Creates an array containing the numbers 1 to 100. Hint: look at the .. operator.
$numbers = @(1..100)
$numbers
13) Write and paste here a piece of code that:
Calculates the total of the numbers in the array $numbers1
$total = 0.0
foreach ( $number in $numbers1) { write "So far the total is $total and the number is $number"
$total = $total + $number}
write "The total is $total "
14) Write and paste here a piece of code that:
Uses a while loop to loops 10 times counting down a rocket launch
$count = 10
While ($count gt 0} {write $count
$count = $count -1} write PESHWWWWWW
15) Write and paste here a piece of code that:
Uses a for loop to loops 10 times counting down a rocket launch
for($count=10; $count -gt 0; $count--){
write $count}
write "LAUNCH STARTED"
16) Write and paste here a piece of code that:
Calculates the average of the numbers in the array $numbers2
$numbers2 | measure -average
17) Write and paste here a piece of code that:
Updates the PowerShell help files
Update-help -Force
18) Write and paste here a piece of code that:
Select the winning Tatslotto numbers and prints them out nicely. Hint: look at the random cmdlet
Random @(1..46) count 6

Signof
Position
Systems
Programmer
(student)
Client
(instructor)

Name & Student


Id
Ahmad Hijazi

Signature

Date

H201405293

9th of September
2015

Nathaly Conlan

11/09/2015

Page 2 of 2

Вам также может понравиться