我的WSUS服务器在没有GUI的情况下运行Server 2016 Core版,因此必须通过powershell安装所有内容。当我运行Adamj_Clean-WSUS.ps1 -FirstRun
时,错误是:
The term 'sqlcmd' is not recognized...
Executing ComputerObjectCleanup
Executing WSUSDBMaintenance
11 Job11 BackgroundJob Failed False localhost sqlcmd -S np:\\.\pipe\...
The term 'sqlcmd' is not recognized as the name of a cmdlet...
You cannot call a method on a null-valued expression.
At C:\Users\user\Documents\Adamj_Clean-WSUS.ps1:2480 char:9
...
You cannot call a method on a null-valued expression.
At C:\Users\user\Documents\Adamj_Clean-WSUS.ps1:2482 char:9
+ $Script:AdamjWSUSDBMaintenanceOutputHTML += $AdamjWSUSDBMaint ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Executing WSUSServerCleanupWizard
_
在跑了几个小时之后,不得不杀死窗户停止它。
答案 0 :(得分:0)
https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility
一种方法是将它们放在另一台服务器上的共享中,然后挂载该共享:
New-PSDrive -Name T -PSProvider FileSystem -Root \\<server_IP>\<share_name> -Credential <domain>\<user>
cp T:\<folder>\msodbcsql.msi.msi .
cp T:\<folder>\MsSqlCmdLnUtils.msi .
cp T:\<folder>\Clean-WSUS.ps1 .
如果您已经习惯按标签键来完成文件名设置,请考虑&#34;。\&#34;自动添加到文件名前是无辜的,请注意它不是:https://superuser.com/a/1310787/891171
msiexec /i msodbcsql.msi /qn IACCEPTMSODBCSQLLICENSETERMS=YES /L*V msodbcsql.log
验证日志:
Get-Content -path .\msodbcsql.log
msiexec /i MsSqlCmdLnUtils.msi /Passive /NoRestart IACCEPTMSSQLCMDLNUTILSLICENSETERMS=YES /L*V MsSqlCmdLnUtils.log
验证日志:
Get-Content -path .\MsSqlCmdLnUtils.log
这是我安装SQLCMD.EXE的地方。 YMMV:
$env:Path += ";C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\"
如脚本中所述(您确实已经阅读了注释并设置了变量,对吧?),首先运行:
PowerShell.exe -ExecutionPolicy Bypass
然后:
Clean-WSUS.ps1 -FirstRun