
wsus 서비스를 재설정하고 선택 가능한 하나 이상의 호스트(최대 200개 호스트)에서 다운로드한 업데이트를 삭제하고 싶습니다.
호스트를 ping하고 파일로 내보내고 싶습니다. 온라인 및 오프라인 결과가 탁월합니다.
***
다음 희망사항은 비밀번호 를 입력할 때 비밀번호 부분에 별표를 표시하는 것입니다 .cls $User = Read-Host "Enter username" $Pass = Read-Host "Enter password" cls
4 필요한 경우 psexec
모든 사람의 호스트에 복사하는 것이 좋습니다 .C:\temp
WSUS 서비스를 재설정하고 다운로드한 업데이트를 삭제하기 위해 bat 파일을 만들었습니다.
clean_wsus.bat file:
net stop wuauserv
net stop bits
cd\
cd C:\Windows\SoftwareDistribution
del *.* /s /q
net start wuauserv
net start bits
wuauclt /resetauthorization /detectnow
이것은 하나의 호스트에서 잘 작동합니다.
이것은 Powershell 스크립트입니다.
$input = Read-Host @"
Select Option
(1)Manually enter computer(s)
(2)Retrieve computer(s) from file
Option
"@
If ($input -eq 1){
$count = Read-Host "How many computers"
$Computers = 1..$count
$b=0;$c=1; ForEach ($Computer in $Computers) {$Computers[$b] = Read-Host "Computer" $c; $b++; $c++}
} ElseIF ($input-eq 2) {
$Computers = Read-Host "File"
$Computers = Get-Content $Computers
} Else {
write-host "Invalid Option"
Exit
}
cls
$User = Read-Host "Enter username"
$Pass = Read-Host "Enter password"
cls
$PSExec = "C:\Temp\PsExec.exe"
ForEach ($Computer in $Computers){
& $PSExec \\$Computer -u $User -p $Pass -h "C:\Temp\clean_wsus.bat"
}
내가 얻는 오류는 다음과 같습니다.
PsExec v2.33 - Execute processes remotely
Copyright (C) 2001-2021 Mark Russinovich
Sysinternals - www.sysinternals.com
PsExec.exe : The handle is invalid.
At C:\Temp\WSUS\Script\WSUS Update.ps1:31 char:1
+ & $PSExec \\$Computer -u $User -p $Pass -h "C:\Temp\clean_wsus.bat"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (The handle is invalid.:String) [], RemoteExce
ption
+ FullyQualifiedErrorId : NativeCommandError
Logon failure: the user has not been granted the requested logon type at this computer.
Connecting to local system...
Connecting to local system...
Starting PSEXESVC service on local system...
Copying authentication key to NB***...
Connecting with PsExec service on NB***..
Starting C:\Temp\clean_wsus.bat on NB***....
Couldn't install PSEXESVC service:
PsExec could not start C:\Temp\clean_wsus.bat on NB***.: