Lab 7: Advanced Powershell for System Administration

Lab 7: Advanced Powershell for System Administration

IT 344

Lab 7: Advanced PowerShell for System Administration

Objectives

Learn to manage Windows 7 systems with advanced PowerShell (PS) features.

Resources:

You can find information in these web resources to help you complete the tasks below

// using windows powershell for administration

// enable remote commands

// remoting in powershell

// invoke-command

Procedures

Please work on this lab with a partner as a team of two. Perform remote execution on each other’s machine.

Part 1 – Remote Execution

Setup your (you and your partner) machines to remotely execute your WMI PS script from Lab 6 on each other’s machine. The resources listed above can be helpful.

Notes:

-You need to enable remote PS, the “winrm” service.

-You need to add each other’s computer as trusted connection.

-You may (or may not) have to modify your script.

-You may (or may not) have to create a remote PS session.

Part 2 – Remote Administration

Use PowerShell to manage remote computers by specifying -ComputerName parameter. Learn to use pipes and filters.

Write PS scripts to do the following tasks:

  1. List all the hot fixes installed on a remote machine that are “Security Update”.
  2. From a list of at least two machines (IP addresses or machine names), find out if hot fix KB2620712 is installed on each of the machines.
  3. For a remote machine, list the MAC addresses and description for all the DHCP enabled adapters.
  4. For a list of at least two machines, renew DHCP lease for all DHCP enabled adapters on each of the machines.
  5. For a list of at least two machines, ping them every 10 seconds and give a message if any of them fails to respond. You can simulate this by disable the network adapter or unplug the cable on the remote machine.

Here are some sample PS scripts that might be helpful for you to get started with your tasks. Try them with a remote machine name (replace “.” with a valid IP address or machine name) and see what they do.

Get-WmiObject -Class Win32_QuickFixEngineering -ComputerName .
Get-WmiObject -Class Win32_QuickFixEngineering -ComputerName . -Property HotFixId | Select-Object -Property HotFixId
Get-WmiObject -Class Win32_QuickFixEngineering -Filter "Description='Security Update'" -ComputerName .
Get-WmiObject -Class Win32_NetworkAdapter -ComputerName .
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "DHCPEnabled=true" -ComputerName . | Format-Table -Property DHCP*
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled=true and DHCPEnabled=true" -ComputerName . | Where-Object -FilterScript {$_.DHCPServer -contains "192.168.0.1"} | ForEach-Object -Process {$_.RenewDHCPLease()}
( Get-WmiObject -List | Where-Object -FilterScript {$_.Name -eq "Win32_NetworkAdapterConfiguration"} ).RenewDHCPLeaseAll()

Get-WmiObject -class Win32_NetworkAdapterConfiguration | Where-Object {$_.IPEnabled -eq 'True'} | Format-Table IPAddress, DefaultIPGateway, MACAddress -auto

(Get-WmiObject -List -ComputerName . | Where-Object -FilterScript {$_.Name -eq "Win32_Share"}).Create("C:\temp","TempShare",0,25,"test share of the temp folder")
(Get-WmiObject -Class Win32_Share -ComputerName . -Filter "Name='TempShare'").Delete()
(New-Object -ComObjectWScript.Network).MapNetworkDrive("B:", "\\FPS01\users")
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName . | Format-Table -Property IPAddress
"127.0.0.1",”192.168.1.1”," | ForEach-Object -Process {Get-WmiObject -Class Win32_PingStatus -Filter ("Address='" + $_ + "'") -ComputerName .} | Select-Object -Property Address,ResponseTime,StatusCode

Pass-off

Show both part 1 and part 2 to TA or instructor.

Write-up instructions

  1. Document your install such that your results could be replicated by another IT student. Include scripts and screenshots (You must include at least the 2 that are mentioned in the procedures).
  2. List any references you used, including links to any websites.