安装 ADFS 会抛出“空参数”

发布于 2024-11-09 16:54:11 字数 1192 浏览 0 评论 0原文

这是我用于安装 ADFS 的脚本的一部分。非常简单,但 Start-Process 似乎正在以一种有趣的方式解析开关。我有什么遗漏的吗?

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)

如果我手动执行完全相同的命令(来自 write-host 的输出),则一切正常。

有什么想法吗? 谢谢。

This is a portion of my script for installing ADFS. Pretty straightforward, but it seems Start-Process is parsing switches in a funny way. Is there something I'm missing?

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}

If I Execute the above script I get the following in a log file:

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)

If I execute the exact same command manually (from the output of write-host), everything works fine.

Any ideas?
Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷了相思 2024-11-16 16:54:11

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

I cant delete the question, but what I found by investigating older logs is that the error occurs even when I run the command the regular way. So the above script is actually working as intended.

初与友歌 2024-11-16 16:54:11

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

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

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

另请注意,您似乎在一个参数中传递了三个命令行参数(/quiet/logfile 和日志文件名)。尝试像这样传递它们:

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

但是,如果这是问题的原因,那么我预计 adfssetup.exe 会抱怨类似 command line argument '/quiet /logfile .. .' 无法识别

(I don't really understand what is happening here, but here are two possibilities.)

One option is that your get-date does not work as you intend. The result is that $logfile contains a percent sign (%), which causes 'format string injection' in the AD FS 2.0 installer. The error message points in that direction.

However, I cannot reproduce that if I run your PowerShell script on my own system.

Also note that it looks like you're passing three command line arguments (/quiet, /logfile, and the log file name) in one argument. Try passing them like so:

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

However, if this were the cause of the problem then I would have expected adfssetup.exe to complain with an error like command line argument '/quiet /logfile ...' not recognized.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文