Lab 9: Programming Assignment - squatchulator/Tech-Journal GitHub Wiki
taskScript.ps1
# Storyline: Grab the network adapter information using the WMI class,
# get the IP address, default gateway, DNS servers, and DHCP server,
# and open/close the calculator app.
# Output of 'Get-WmiObject' piped to 'Select-Object', followed by object
# parameters to display.
Get-WmiObject -Class Win32_NetworkAdapterConfiguration | `
Select-Object IPAddress, DHCPServer, DefaultIPGateway, DNSServerSearchOrder
# Export running processes to a CSV file
Get-Process | Select-Object ProcessName, Path, ID | `
Export-Csv -Path "C:\Users\Miles\Desktop\Processes.csv" -NoTypeInformation
# Export running services to a CSV file
Get-Service | Where { $_.Status -eq "Running" } | `
Export-Csv -Path "C:\Users\Miles\Desktop\Services.csv" -NoTypeInformation
# Start the calculator app
Start-Process -FilePath "calc.exe"
# Wait 5 seconds so the calculator app has time to load up before being closed
Start-Sleep -Seconds 5
# Stop the calculator app
Get-Process -Name "CalculatorApp" | Stop-Process -Force