Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 安装ADF会抛出一个“错误”;空参数";_Powershell_Installation_Adfs - Fatal编程技术网

Powershell 安装ADF会抛出一个“错误”;空参数";

Powershell 安装ADF会抛出一个“错误”;空参数";,powershell,installation,adfs,Powershell,Installation,Adfs,这是我安装ADFS脚本的一部分。非常简单,但启动过程似乎以一种有趣的方式解析开关。有什么我遗漏的吗 write-host "Installing ADFS - process should take 30-45 seconds" $installtime=get-date -uformat "%Y_%h_%d_%H_%M" $logfile="$pwd\adfssetup_$installtime.log" $ADFSInstall = "AdfsSetup.exe" $ADFSInstallP

这是我安装ADFS脚本的一部分。非常简单,但启动过程似乎以一种有趣的方式解析开关。有什么我遗漏的吗

write-host "Installing ADFS - process should take 30-45 seconds"
$installtime=get-date -uformat "%Y_%h_%d_%H_%M"
$logfile="$pwd\adfssetup_$installtime.log"
$ADFSInstall = "AdfsSetup.exe"
$ADFSInstallParams = '/quiet /logfile '+$logfile
Start-Process $ADFSInstall $ADFSInstallParams -wait
if ({gc -path $logfile | select-string -pattern "AD FS 2.0 is already installed on this computer"} -eq $null){write-host -ForegroundColor Cyan "ADFS Installed"} Else{write-host -ForegroundColor "There was an error Installing ADFS, please check the log file: $logfile;break}
如果执行上述脚本,我将在日志文件中获得以下内容:

Microsoft.IdentityServer.Setup Error: 5124 : 6 [ 2070099085 ]: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args) at Microsoft.IdentityServer.Setup.Diagnostics.TraceLog.WriteLine(TraceEventType eventType, String msg, Object[] args) Microsoft.IdentityServer.Setup错误:5124:6[2070099085]:System.FormatException:索引(从零开始)必须大于或等于零且小于参数列表的大小。 位于System.Text.StringBuilder.AppendFormat(IFormatProvider提供程序,字符串格式,对象[]args) 位于Microsoft.IdentityServer.Setup.Diagnostics.TraceLog.WriteLine(TraceEventType事件类型,字符串消息,对象[]参数) 如果我手动执行完全相同的命令(从write host的输出),那么一切都可以正常工作

有什么想法吗? 谢谢。

(我不太明白这里发生了什么,但这里有两种可能性。)

一种选择是,您的
获取日期
无法按预期工作。结果是,
$logfile
包含一个百分号(
%
),这会导致AD FS 2.0安装程序中出现“格式字符串注入”。错误消息指向该方向

但是,如果我在自己的系统上运行您的PowerShell脚本,我将无法重现这种情况

还要注意,它看起来像是在一个参数中传递三个命令行参数(
/quiet
/logfile
,以及日志文件名)。试着这样通过他们:

$ADFSInstallParams = @('/quiet', '/logfile', $logfile)
Start-Process $ADFSInstall @ADFSInstallParams -wait

但是,如果这是问题的原因,那么我希望
adfssetup.exe
会抱怨出现错误,如
命令行参数“/quiet/logfile…”无法识别

我无法删除该问题,但我通过调查旧日志发现,即使在我以常规方式运行命令时,也会发生错误。因此,上面的脚本实际上正在按预期工作。

你说得对。我通过调查较旧的日志(实际上是运行了undelete程序来获取日志)发现,即使我以常规方式运行ADFSSetup.exe,也会出现错误。因此,上面的脚本实际上按照预期工作。谢谢你的帮助,这里没人接。让我们猜猜。。。在$pwd中,路径中是否有空白?