我需要在300多个服务器中应用SQL Server修补程序,所以,我在下面创建了代码并将其保存为Apply_SQL_Patch.ps1。Powershell应用SQL修补程序多个服务器
我正在阅读包含所有服务器名称的txt文件,并且想要连接到它们,提取并应用修补程序。
的问题是,当我执行它,将它连接到服务器,但它不改变目录到d:\ SOFTWARE \补丁,从而对未来行错误:
$output = foreach ($cluster in GC "D:\Software\Patch\Servers_List.txt")
{
Enter-PSSession -ComputerName $cluster
cd D:\Software\Patch\
.\SQLServer2014-KB4037356-x64.exe /X:D:\Software\Patch
.\setup.exe /action=patch /instancename=SQL2014 /quiet /IAcceptSQLServerLicenseTerms
}
$output | Out-File -Append D:\Software\Patch\Patch_Result.txt
错误如下:
\ SQLServer2014-KB4037356-x64.exe程序:术语 不被识别为一个 cmdlet,函数的名称,脚本文件或可操作的程序 '\ SQLServer2014-KB4037356-x64.exe程序。'。检查名称的拼写 ,或者如果包含路径,请确认路径为 正确,然后重试。在D:\ software \ patch \ Apply_SQL_Patch.ps1:5 char:2 +。\ SQLServer2014-KB4037356-x64.exe/X:D:\ Software \ Patch + ~~~~~~~~~~~ (。\ SQLServer2014-KB4037356-x64.exe:String)[], CommandNotFoundException + FullyQualifiedErrorId: CommandNotFoundException
。\ setup.exe:术语'。\ setup.exe'不被识别为名称为 的cmdlet,函数,脚本文件或可操作程序。检查名称的拼写,或者如果包含路径,请确认路径 是正确的,然后重试。在D:\ software \ patch \ Apply_SQL_Patch.ps1:7 char:2 +。\ setup.exe/action = patch/instancename = SQL2014/quiet/IAcceptSQLServerLicense ... + ~~~~~~~~~ ~~ + CategoryInfo:ObjectNotFound:(\ SETUP.EXE:字符串)[],CommandNotFoundException + FullyQualifiedErrorId:CommandNotFoundException
感谢您的帮助!
补丁300 + Sql Server实例肯定听起来像你真的需要一个配置管理解决方案。话虽如此,你是否已将补丁文件复制到远程服务器呢? – vonPryz
Hi @ vonPryz!感谢回复!是的,补丁存在于名为:( – AdemirP