English 中文(简体)
安装ADFS会抛出“null参数”
原标题:Installing ADFS throws a "null parameter"

这是我安装ADFS脚本的一部分。相当简单,但StartProcess似乎以一种有趣的方式解析开关。我有什么东西不见了吗?

write-host "Installing ADFS - process should take 30-45 seconds"
$installtime=get-date -uformat "%Y_%h_%d_%H_%M"
$logfile="$pwdadfssetup_$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)

如果我手动执行完全相同的命令(从写主机的输出),一切都很好。

Any ideas? Thank you.

最佳回答

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

问题回答

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

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

但是,如果我在自己的系统上运行你的PowerShell脚本,我就无法重现这一点。

还要注意,看起来您在一个参数中传递了三个命令行参数(/quiet/lofile和日志文件名)。试着这样传递它们:

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

然而,如果这是问题的原因,那么我希望adfssetup.exe会抱怨一个错误,比如命令行参数/quiet/lofile。。。无法识别





相关问题
Correct place to install demostration projects?

With the new Windows 7 restrictions (well, new to Windows Vista anyways), we can no longer install demo projects to %ProgramFilesFolder%OurApplicationdemo since restricted users will not be able to ...

.deb package conffiles problem

I am distributing one of my applications using a .deb package, but have a problem relating to one of the files. The distribution includes a database file which is constantly updated by the app, on a ...

Closing an application using WiX

In creating my WiX installer I have run into an issue when trying to close an application before installing the upgrade. Below is an example of how I am attempting to do this. <util:...

VS 2005 Setup - HKCU

I am trying to fix an existing application that uses a Visual Studio 2005 setup project. We are requiring it to work on limited user accounts for XP, our app is written in C# for .Net 2.0. It writes ...

Do I want Publish or Release Build in VB.net?

I wrote a little (like 40 lines little) Winforms application with VB.net in Visual Studio 2010. Now I ve released the code as a Google Code project. It s easy for a developer to get the source but I d ...

configsource and installer

I have an project csproj, with app.config file, and logging Ent.Library section using configsource attribute. The logging section is in ahother file Configloggingconfiguration.config. I have a ...

热门标签