2

I have a basic function:

Function Write-AdvancedLog{
    [CmdletBinding()]
    Param(
        $WriteToEtl,
        $Message,
        $CurrentFunction
    )
}

Essentially I want to specify a parameter -WriteToEtl without specifying a value. If the parameter is added to the Function call (Write-AdvancedLog -WriteToEtl) it will do a certain thing, if the switch isn't specified, it won't.

How can I achieve this?

1
  • 6
    [switch]$WriteToEtl Commented Sep 16, 2017 at 20:31

1 Answer 1

5

There's a switch data-type just for that. You can specify this using [switch]$WriteToEtl

Good resource: http://sinairv.github.io/blog/2015/05/18/powershell-the-switch-data-type/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.