#>[CmdletBinding(SupportsShouldProcess=$true)]param([string]$Mode,[parameter(ValueFromPipeline=$true,Mandatory=$true)][object[]]$ServiceCollection)begin{$callStack=Get-PSCallStackif($callStack.Length-gt1){$callerName=$callStack[1].Command}else{$callerName=$callStack[0].Command}$ProcessArray=@()}process{#Get all the objects from the pipeline before proceeding$ProcessArray+=$ServiceCollection}end{$ProcessArray=$ProcessArray|Where-Object{(!$InstanceName-or$_.InstanceName-in$InstanceName)-and(!$Type-or$_.type-in$Type)}foreach($servicein$ProcessArray){#Get WMI object$Wmi=Get-WmiObjectWin32_Service-ComputerName$service.ComputerName-filter"name='$($service.ServiceName)'"if($Pscmdlet.ShouldProcess($Wmi,"Changing the Start Mode to $Mode")){$x=$Wmi.ChangeStartMode($Mode)if($x.ReturnValue-ne0){Write-Message-LevelWarning-EnableException$EnableException-FunctionName$callerName-Message("The attempt to $action the service $($job.ServiceName) on $($job.ComputerName) returned the following message: "+(Get-DbaSQLServiceErrorMessage$x.ReturnValue))}}}}}