# Function Parameter that is only $true if specified - similar to -verbose

**URL:** https://forums.powershell.org/t/function-parameter-that-is-only-true-if-specified-similar-to-verbose/17765
**Category:** PowerShell Help
**Created:** [October 16, 2021, 12:44pm UTC](https://forums.powershell.org/t/function-parameter-that-is-only-true-if-specified-similar-to-verbose/17765 "2021-10-16T12:44:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![PinPinPoola](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/pinpinpoola/32/1779_2.png) [@PinPinPoola](https://forums.powershell.org/u/PinPinPoola)
#### Post date: [October 16, 2021, 12:44pm UTC](https://forums.powershell.org/t/function-parameter-that-is-only-true-if-specified-similar-to-verbose/17765/1 "2021-10-16T12:44:44Z")

</div>

Hello,

I have created a function where I would like to optionally specify a parameter called `-update` that is `$true` (or is **not** `$null`) only when specified, but I don’t want to call it as `-update $true`

Similar to `-verbose` in that specifying `$true` is not required, as it is _inferred_ to be `$true` / not `$null`

Is this possible?

Many Thanks,  
Pin

---

<div class="post-metadata">

### Author: ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)
#### Post date: [October 16, 2021, 1:53pm UTC](https://forums.powershell.org/t/function-parameter-that-is-only-true-if-specified-similar-to-verbose/17765/2 "2021-10-16T13:53:36Z")

</div>

Pin Pin Poola.  
Welcome to the forum. 👋🏽

> [@PinPinPoola](#):
>
> Is this possible?

Yes, it is. Those parameters are called **switch parameters**. Here you can read more about:

> **[about Functions Advanced Parameters - PowerShell](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-7.4&viewFallbackFrom=powershell-7.1)**
>
> Explains how to add parameters to advanced functions.

---

<div class="post-metadata">

### Author: ![PinPinPoola](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/pinpinpoola/32/1779_2.png) [@PinPinPoola](https://forums.powershell.org/u/PinPinPoola)
#### Post date: [October 16, 2021, 2:19pm UTC](https://forums.powershell.org/t/function-parameter-that-is-only-true-if-specified-similar-to-verbose/17765/3 "2021-10-16T14:19:42Z")

</div>

Hello @Olaf

Thank you for the kind welcome and for the information on **switch parameters**.

I really appreciate it.

Thx  
Pin.

---

<div class="post-metadata">

### Author: ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)
#### Post date: [May 16, 2024, 8:21pm UTC](https://forums.powershell.org/t/function-parameter-that-is-only-true-if-specified-similar-to-verbose/17765/4 "2024-05-16T20:21:09Z")

</div>


