Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#1. Make variables # Make a variable named $RoomNum and use Read-Host to prompt the user with the following message: # Please Enter your Room

#1. Make variables # Make a variable named "$RoomNum" and use Read-Host to prompt the user with the following message: # "Please Enter your Room Number (219, 220, or 221)" # Run this line of code and it will prompt you for the room number # The results should store the room number within the variable

#2. Write three IF statements to assign values to variables based on room number # Write three IF statements to assign a file location to the "$Path" variable and a static printer IP Address to the $PrinterIP variable # based on the value stored in $RoomNum # If value stored in $RoomNum is 219 do this: # $Path = "C:\InstallFiles\RM219" # $PrinterIP = "192.168.219.6" # If value stored in $RoomNum is 220 do this: # $Path = "C:\InstallFiles\RM220" # $PrinterIP = "192.168.220.6" # If value stored in $RoomNum is 221 do this: # $Path = "C:\InstallFiles\RM221" # $PrinterIP = "192.168.221.6"

#3. Copy and install software from a local fileshare using variables and conditional logic

# Step 1: Write the PowerShell syntax to check to see if Java 32bit and 64bit is currently installed # Make a variable named $Java, then use the Get-WmiObject cmdlet with the class Win32_Product, Pipe the results # to the Where-Object cmdlet and filter for only software where the name contains the word "Java" # The results should be stored in the within the $Java variable

# Step 2: Write an If-Else statement to test if the Java software is currently installed, if it is not installed, Install it # IF condition tests to see if $Java is empty ($Null) # (meaning that "Step 1" did not find software installed where the name contains the word "Java") # # If this is TRUE, # -Use write-host to display the message "Installing Java Software" # -Write the code to copy the software from the souce location (the $Path variable) to the destination C:\JavaInstall # # -Write the PowerShell syntax to install Java 32bit and 64bit from the C:\JavaInstall folder # You will write two separate commands; one to install the 32bit and another to install the 64bit # Use the cmdlet "Start-Process" to accomplish the installations # The required argument needed by the Java installer to install silently is "INSTALL_SILENT=Enable" # Make each command wait until the installation is completed before processing the next command # -Write the PowerShell syntax to verify that Java 32bit and 64bit installed Successfully # -Write the PowerShell syntax to delete the "C:\JavaInstall" folder # ELSE condition means that the Java software is already installed, and there is no need to install it now # -Use write-host to display the message "Java is Already Installed: No Need to Install the software"

#4. Installing a local IP printer using variables and conditional logic

# Step 1 : Write the PowerShell syntax to check to see if a printer is already installed with the vaulue of the $RoomNum variable within the printer name # Write the code to extract the Name (as string) of a Printer where the Printer Name contains the value stored in $RoomNum # and save the results in a variable named "$Printer"

# Step 2: Write an If-Else statement to test if the printer is currently installed, if it is not installed, Install it # IF condition tests to see if $Printer is empty ($Null) # (meaning that "Step 1" did not find a Printer where the Printer Name contains the value stored in $RoomNum) # # If this is TRUE, # -Use write-host to display the message "Installing Printer" # -Make a variable named $Driver and use a parenthetical to extract the Name (as string) of the Print Driver where the name contains # the word "Universal". The results of the parenthetical should store the Print Driver name within the variable # -Write the PowerShell syntax to add a new printer port with the name "Port$RoomNum", use the value stored in the # $PrinterIP variable as the PrinterHostAddress (IP Address) # -Make a variable named $Port and use a parenthetical to extract the Name (as string) of the Print Port where the name contains # the vaule stored in the $RoomNum variable. The results of the parenthetical should stored within the variable # -Add a printer named "HP-Printer-$RoomNum", use the variables you made to pass info to the -DriverName and -PortName parameters # -Write the PowerShell syntax to verify that the printer installed Successfully # ELSE condition means that a printer with is already installed, and there is no need to install it now # -Use write-host to display the message "Printer is Already Installed: No Need to Install the printer"

#5. Use Enter-PSSession to make a non-persistent One-to-One remote connection to Client1. # Once remotely connected to Client1, complete the following tasks on Client1: <# Write the PowerShell syntax to display four custom properties of the Get-ComputerInfo cmdlet in List format. The custom List properties should be labed HostName, RAM(MB), OS_Version, and BuildNumber. To make these custom properties, convert CsDNSHostName into HostName, CsPhyicallyInstalledMemory into RAM(MB), WindowsProductName into OS_Version, and OsBuildNumber info BuildNumber The RAM(MB) should be displayed in MegaBytes. The default output is listed in KB, so divide the output by 1KB to get the proper units (display as INT) Finally, disconnect the remote One-to-One connection to Client1 #>

#6. Use Invoke-Command to make non-persistent Remote Connection to Client1 <# -Have the remote computer do the following tasks (all these tasks should happen on the remote computer): Get a list of processes Filter where CPU is greater than 10 Sort by CPU Descending Only display the top 10 processes -Sort the returned info by PSComputername and format into a table showing ProcessName, ID, CPU (with 2 decimal places), and PSComputername (happens locally) #>

#7. Write the PowerShell syntax to do the following: <# Creat a variable named "$Sessions" and use a parenthetical to Open a reusable session to Client1 and store the newly made session in $Sessions Display all currently open sessions #>

#8. Write the PowerShell syntax to Use Invoke-Command with a persistent session to the computer(s) stored in the $Sessions variable to do the following: <# Write three separate Invoke-Command statements to make three different variables (One variable per invoke-command statement) $Var1 = 5 $Var2 = 10 $Var3 = 2 Write another Invoke-Command statement to display the values stored within these variables: The display should read "The stored values of the variables are:" and then list the values #>

#9. Write the PowerShell syntax to Use Invoke-Command with a persistent session to the computer(s) stored in the $Sessions variable to do the following: <# Make a new variable named $Calc Perform the following math calculation using the values stored in the three variables $Var1, $Var2, and $Var3 and store the result in $Calc $Var1 * $Var2 / $Var3 Display the value stored in $Calc, The display should read "The value stored in $Calc is:" and then list the value #>

#10. Write the PowerShell syntax to do the following: <# Close all the persistent sessions for the computer(s) stored in the $Sessions variable List all open sessions to prove that there are no sessions still open #>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions