-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestlab.ps1
More file actions
31 lines (29 loc) · 976 Bytes
/
testlab.ps1
File metadata and controls
31 lines (29 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function Optimize-LocalSystem {
[CmdletBinding(SupportsShouldProcess)]
param (
[Parameter(Mandatory, ParameterSetName='IndividualParams')]
[ValidateSet('CleanTempFiles', 'CheckUpdates')]
[string]$Operation,
[Parameter(Mandatory, ParameterSetName='CSVInput')]
[PSCustomObject]$CSVRow
)
switch ($PSCmdlet.ParameterSetName) {
'CSVInput' {
$Operation = $CSVRow.Operation
}
}
switch ($Operation) {
'CheckUpdates' {
Write-Host 'Check for Windows updates.'
}
'CleanTempFiles' {
if ($PSCmdlet.ShouldProcess('Temporary files', 'Remove')) {
Remove-Item "C:\Temp\NonExistentFile.txt" -ErrorAction Stop
Write-Host 'Cleaning temp files.'
}
}
Default {
Write-Error "Invalid operation. You chose $_, but that option is not handled in the switch statement."
}
}
}