How do i invoke sc create from a powershell script
问题 I want to invoke sc create from a powershell script. Here is the code. function Execute-Command { param([string]$Command, [switch]$ShowOutput=$True) echo $Command if ($ShowOutput) { Invoke-Expression $Command } else { $out = Invoke-Expression $Command } } $cmd="sc create `"$ServiceName`" binpath=`"$TargetPath`" displayname=`"$DisplayName`" " Execute-Command -Command:$cmd which gives the following error: Set-Content : A positional parameter cannot be found that accepts argument 'binpath=...'.