PowerShell Lab – Process and File Management 1 - Snowboundport37/champlain GitHub Wiki
PowerShell Lab – Process and File Management 1
Course: CSI-230 / SYS-320
Student: Andrei Gorlitsky
Objective
Create basic PowerShell commands to perform process and file management tasks.
Deliverables
1. List every process for which ProcessName starts with C
Get-Process | Where-Object { $_.ProcessName -like 'C*' } | Select-Object Id, ProcessName, CPU, PM
Screenshot:
2. List every process for which the path does not include system32
Get-CimInstance Win32_Process | Where-Object { $_.ExecutablePath -and $_.ExecutablePath -notmatch '(?i)\\system32\\' } | Select-Object ProcessId, Name, ExecutablePath
Screenshot:
3. List every stopped service, order alphabetically, and save to CSV
Get-Service | Where-Object Status -eq 'Stopped' | Sort-Object Name | Export-Csv -Path .\stopped_services.csv -NoTypeInformation
Get-Item .\stopped_services.csv
Screenshot:
4. Chrome Toggle Script
# Toggle-ChamplainChrome.ps1
$chromeProcs = Get-Process -Name chrome -ErrorAction SilentlyContinue
if (-not $chromeProcs) {
$paths = @(
"$env:ProgramFiles\Google\Chrome\Application\chrome.exe",
"$env:ProgramFiles(x86)\Google\Chrome\Application\chrome.exe",
"chrome.exe"
)
$chromePath = $paths | Where-Object { Test-Path $_ } | Select-Object -First 1
if (-not $chromePath) {
throw "Chrome not found."
}
Start-Process -FilePath $chromePath -ArgumentList "https://www.champlain.edu"
Write-Host "Started Chrome to champlain.edu"
} else {
Stop-Process -Id $chromeProcs.Id -Force
Write-Host "Stopped Chrome ($($chromeProcs.Count) instance(s))"
}
Screenshots:
Notes
- All commands have been tested and verified to work correctly
- Screenshots should be added to demonstrate the output of each command
- The CSV file will be created in the current directory when running command #3
- The Chrome toggle script handles multiple Chrome installations and provides appropriate feedback