PowerShell的:脚本启动带有参数的程序? [英] powershell: script to start a program with parameters?
问题描述
当我运行PowerShell脚本下面我收到以下错误。我如何通过运行PowerShell的带参数的程序?该脚本将组策略登录。
调用-Ex的pression:位置参数不能被发现
接受参数'\\ TBHSERVER \\ NETLOGON \\ BGInfo \\ BGIFILE.bgi /定时器:0 /秒
ilent / nolicprompt。在
X:\\系统\\脚本\\ PowerShell的\\ UpdateDesktopWithBGInfo.ps1:6字符:18
+调用-Ex的pression<<<< $ logonpath $ ArguList
+ CategoryInfo:InvalidArgument:(:) [调用-Ex的pression],ParameterBindingException
+ FullyQualifiedErrorId:PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeEx pressionCommand
块引用>$ LogonPath = $ ENV:LOGONSERVER +\\ NETLOGON \\ BGInfo \\ Bginfo.exe
$ ArguList = $ ENV:LOGONSERVER +\\ NETLOGON \\ BGInfo \\ BGIFILE.bgi /定时器:0 /静音/ nolicprompt
调用命令$ LogonPath
调用-Ex的pression $ logonpath $ ArguList
解决方案试试这个:
&安培; \\\\ $ ENV:LOGONSERVER \\ NETLOGON \\ BGInfo \\ Bginfo.exe\\\\ $ ENV:LOGONSERVER \\ NETLOGON \\ BGInfo \\ BGIFILE.bgi/定时器:0 /静音/ nolicprompt
如果该BGIFILE.bgi驻留在相同的位置,然后Bginfo.exe你可以仅指定文件名:
&安培; \\\\ $ ENV:LOGONSERVER \\ NETLOGON \\ BGInfo \\ Bginfo.exeBGIFILE.bgi /定时器:0 /静音/ nolicprompt
When i run the Powershell script below i receive the error below. How do i run programs through powershell with parameters? The script will be a group policy logon.
Invoke-Expression : A positional parameter cannot be found that accepts argument '\TBHSERVER\NETLOGON\BGInfo\BGIFILE.bgi /timer:0 /s ilent /nolicprompt '. At X:\Systems\scripts\PowerShell\UpdateDesktopWithBGInfo.ps1:6 char:18 + Invoke-Expression <<<< $logonpath $ArguList + CategoryInfo : InvalidArgument: (:) [Invoke-Expression], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeExpressionCommand
$LogonPath = $env:LOGONSERVER + "\NETLOGON\BGInfo\Bginfo.exe" $ArguList = $env:LOGONSERVER + '\NETLOGON\BGInfo\BGIFILE.bgi /timer:0 /silent /nolicprompt ' invoke-command $LogonPath Invoke-Expression $logonpath $ArguList
解决方案Try this:
& "\\$env:LOGONSERVER\NETLOGON\BGInfo\Bginfo.exe" "\\$env:LOGONSERVER\NETLOGON\BGInfo\BGIFILE.bgi" /timer:0 /silent /nolicprompt
If the BGIFILE.bgi reside in the same location as Bginfo.exe then you can specify only the file name:
& "\\$env:LOGONSERVER\NETLOGON\BGInfo\Bginfo.exe" BGIFILE.bgi /timer:0 /silent /nolicprompt
这篇关于PowerShell的:脚本启动带有参数的程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!