Answered You can hire a professional tutor to get the answer.

QUESTION

Overview In this part of your project, you will start creating the script that will be your final project. This step will include:

Overview

In this part of your project, you will start creating the script that will be your final project. This step will include:

  • Identifying the functions and variables that you need
  • Creating the appropriate comments
  • Locating the commands that you will need to perform the basic tasks in the script

Tasks

  1. Review the technical requirements for the project in the Project Overview.
  2. Review the task that you chose for your project.
  3. Open the script you created previously that contained the pseudo code for your project script.
  4. Create the variable assignments that you identified in your pseudo code and any additional that you may need.
  • Implement any trace code at this time for later debugging (Write-Debug statements).
  1. Create the function statements that you identified in your pseudo coded and any additional that you may need.
  • At this point, you may wish to just add a line that shows you entered the function and it is not yet implemented.
  • Implement any trace code in your functions for later debugging.
  1. Implement the logic in the main loop of your program.
  2. Identify that commands that you will use in the main body and function statements.
  3. Add any additional comments about the operation of the functions or logic that you have not yet implemented.

Here is the Code

Pseudo Code

Start

Declarations

//Define the variables

PrinterIP = "10.10.10.10"

PrinterPort = "9100"

PrinterPortName = "IP_" + PrinterIP

DriverName = "KONICA MINOLTA bizhub C35P PS"

DriverPath = "\UNC_PathToMyDrivers"

DriverInf = "\UNC_PathToMyDriversKOBJQA__.inf"

PrinterCaption = "Konica Minolta C35P"

//Define Computer List

//Option 1

ComputerList = ("Jakob", "Gloria")

//Option2

ComputerList = ()

//Import-Csv "C:TempComputersThatNeedPrinters.csv"

//Function to Create a Printer Port

Function CreatePrinterPort( PrinterIP, PrinterPort, PrinterPortName, ComputerName)

//Function to Install Printer Driver

Function InstallPrinterDriver (DriverName, DriverPath, DriverInf, ComputerName)

//Function to Create Printer

Function (PrinterCaption, PrinterPortName, DriverName, ComputerName)

//Function for each computer in the list

Function ForEach(Computer in ComputerList)

Real PowerShell Script Code

####################################################

# Change these values to the appropriate values in your environment

$PrinterIP = "10.10.10.10"

$PrinterPort = "9100"

$PrinterPortName = "IP_" + $PrinterIP

$DriverName = "KONICA MINOLTA bizhub C35P PS"

$DriverPath = "\UNC_PathToMyDrivers"

$DriverInf = "\UNC_PathToMyDriversKOBJQA__.inf"

$PrinterCaption = "Konica Minolta C35P"

####################################################

### ComputerList Option 1 ###

# $ComputerList = @("lana", "lisaburger")

### ComputerList Option 2 ###

# $ComputerList = @()

# Import-Csv "C:TempComputersThatNeedPrinters.csv" | `

# % {$ComputerList += $_.Computer}

Function CreatePrinterPort {

param ($PrinterIP, $PrinterPort, $PrinterPortName, $ComputerName)

$wmi = [wmiclass]"\$ComputerNamerootcimv2:win32_tcpipPrinterPort"

$wmi.psbase.scope.options.enablePrivileges = $true

$Port = $wmi.createInstance()

$Port.name = $PrinterPortName

$Port.hostAddress = $PrinterIP

$Port.portNumber = $PrinterPort

$Port.SNMPEnabled = $false

$Port.Protocol = 1

$Port.put()

}

Function InstallPrinterDriver {

Param ($DriverName, $DriverPath, $DriverInf, $ComputerName)

$wmi = [wmiclass]"\$ComputerNameRootcimv2:Win32_PrinterDriver"

$wmi.psbase.scope.options.enablePrivileges = $true

$wmi.psbase.Scope.Options.Impersonation = `

[System.Management.ImpersonationLevel]::Impersonate

$Driver = $wmi.CreateInstance()

$Driver.Name = $DriverName

$Driver.DriverPath = $DriverPath

$Driver.InfName = $DriverInf

$wmi.AddPrinterDriver($Driver)

$wmi.Put()

}

Function CreatePrinter {

param ($PrinterCaption, $PrinterPortName, $DriverName, $ComputerName)

$wmi = ([WMIClass]"\$ComputerNameRootcimv2:Win32_Printer")

$Printer = $wmi.CreateInstance()

$Printer.Caption = $PrinterCaption

$Printer.DriverName = $DriverName

$Printer.PortName = $PrinterPortName

$Printer.DeviceID = $PrinterCaption

$Printer.Put()

}

foreach ($computer in $ComputerList) {

CreatePrinterPort -PrinterIP $PrinterIP -PrinterPort $PrinterPort `

-PrinterPortName $PrinterPortName -ComputerName $computer

InstallPrinterDriver -DriverName $DriverName -DriverPath `

$DriverPath -DriverInf $DriverInf -ComputerName $computer

CreatePrinter -PrinterPortName $PrinterPortName -DriverName `

$DriverName -PrinterCaption $PrinterCaption -ComputerName $computer

}

####################################################

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question