How to omit script blocks?

I have a script that creates users on AD, syncs the DCs, Syncs to Azure and creates Office 365 subscription. I’d like to make this script public, but not sure how to skip the sections the user might not want to run. (ie… Sync to Azure AD).

 

well, that’s were the design considerations apply. You can have functions for all these capabilities and use Switch parameters to change the behavior or some other parameter where its value will decide which or what functions has to be called.

function DoThis {
    # code here
}

function DoThat {
    # code here
}

function DoAction {
Param(
    [switch]$This,
    [switch]$That
)
    if($This.IsPresent){
      DoThis
    }

    if($That.IsPresent){
      DoThat
    }

}

# OR

function DoAction {
Param(
    [ValidateSet('This','That')]
    [string[]]$Action
)
    switch($Action){
        'This' {DoThis}
        'That' {DoThat}
    }
}

Okay, just to verify you would create functions inside this script for instance, the Sync to Azure AD, then if the user did not supply a parameter for that function it wouldn’t run?

yep.