从PowerShell脚本(日志)重新启动apache web服务器
我有一个powershell脚本,可以在我的机器上重新启动Apache Web服务器。脚本工作正常,但日志报告错误。错误似乎来自Powershell,而不是Apache,因为如果我只执行从PowerShell脚本(日志)重新启动apache web服务器,powershell,powershell-4.0,Powershell,Powershell 4.0,我有一个powershell脚本,可以在我的机器上重新启动Apache Web服务器。脚本工作正常,但日志报告错误。错误似乎来自Powershell,而不是Apache,因为如果我只执行 .\httpd.exe -k config 我没有错误,第一个 .\http.exe -k restart 也不会给出错误。(注意:Powershell在第11行投诉,而不是第10行第一次调用httpd.exe)。我正在Windows 7上使用powershell V4 所以我想了解Powershell
.\httpd.exe -k config
我没有错误,第一个
.\http.exe -k restart
也不会给出错误。(注意:Powershell在第11行投诉,而不是第10行第一次调用httpd.exe)。我正在Windows 7上使用powershell V4
所以我想了解Powershell在这里做什么,因为我认为Apache工作得很好
以下是脚本:
# This PowerShell script restarts apache
start-transcript -Path install.log -Append
Write-Host "apache.ps1 Script`r`n"
$sixtyfour = [Environment]::Is64BitProcess
$exe = "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe"
Write-Host "64-Bit Powershell: "$sixtyfour
& $exe -k restart *>> install.log
Write-Host ""
& $exe -k config *>> install.log
以下是日志:
httpd.exe : Reconfiguring the Apache2.2 service
At G:\wwwroot\setup\apache.ps1:11 char:1
+ & $exe -k config *>> install.log
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Reconfiguring the Apache2.2 service:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
The Apache2.2 service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
刚刚发现将错误重定向到字符串。请参见以下答案#2: 这让你想到: