How to omit powershell parameter from cmdlet if value not provided?

前端 未结 3 1810
青春惊慌失措
青春惊慌失措 2021-01-27 07:21

I\'m trying to execute a below Powershell command to create a new address list on exchange server with parameters like Name, Container, etc.

Container is an

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-27 07:36

    take a look at Get-Help *splatting to see a way to do this.

    a bit more detail ... a "splat" is a hashtable of parameter = value pairs. once you have the basic always-there items in the splat, you can add others just as you would to any hashtable by $Param_Splat.Add(ParameterName, 'Value'). then when you call your cmdlet, you use Verb-Noun @Param_Splat. note the @ symbol instead of the usual $. [grin]

    take care,
    lee

提交回复
热议问题