forked from sagarv26/powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-Rectangle.ps1
More file actions
33 lines (29 loc) · 785 Bytes
/
Get-Rectangle.ps1
File metadata and controls
33 lines (29 loc) · 785 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
32
33
Function Get-Rectangle {
Param (
[parameter()]
[int]$Length,
[parameter()]
[int]$Width,
[parameter()]
[int]$Area
)
If ($PSBoundParameters.ContainsKey('Length') -AND $PSBoundParameters.ContainsKey('Width')) {
$Area = $Width * $Length
}
ElseIf ($PSBoundParameters.ContainsKey('Area') -AND $PSBoundParameters.ContainsKey('Length')) {
$Width = $Area / $Length
}
ElseIf ($PSBoundParameters.ContainsKey('Area') -AND $PSBoundParameters.ContainsKey('Width')) {
$Length = $Area / $Width
}
Else {
Break
}
[pscustomobject]@{
Length = $Length
Width = $Width
Area = $Area
}
}
Get-Rectangle -Length 10 -Width 5
Get-Rectangle -Width 5 -Area 50