Thursday 15 March 2012

Software Update sonrasi yeniden baslatmaya ihtiyac duyan bilgisayarlari listeleme

Asagidaki script size WSUS veya Windows Update den updatelerini cekip kurmus ancak kurulum sonra yeniden baslatmaya ihtiyac duyan bilgisayarlari listeleyerek buyuk kolaylik saglayacaktir, ornek script :
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null

if (!$wsus) {
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();
}

$computerScope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope;
$computerScope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::InstalledPendingReboot;

$updateScope = new-object Microsoft.UpdateServices.Administration.UpdateScope;
$updateScope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::InstalledPendingReboot;

$computers = $wsus.GetComputerTargets($computerScope);

$computers | foreach-object {
$_.FullDomainName | write-host;

# Show which updates are causing the reboot required for the computer. Remove the next 5 lines to only generate a list of computers.
$updatesForReboot = $_.GetUpdateInstallationInfoPerUpdate($updateScope);
$updatesForReboot | foreach-object {
$neededUpdate = $wsus.GetUpdate($_.UpdateId);
" "+$neededUpdate.Title | write-host;
# Remove previous lines to only show computers that need updates
}

}
Ornegin bu scriptte hangi updatelerin yuklendigi hakkinda bilge veren kismi cikartarak kendinize sadece bilgisayar isimlerinden olusan bir cikti hazirlayabilirsiniz de , ve bu ciktiyi SCOM/MOM gibi bir sunucuda Task tanimlayarak haftalik yeniden baslatma zamanlamasi yapabilirsiniz. Bunun icin
sadece bu kismini kullanmaniz yeterli olacaktir.

[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null

if (!$wsus) {
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer();
}

$computerScope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope;
$computerScope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::InstalledPendingReboot;

$updateScope = new-object Microsoft.UpdateServices.Administration.UpdateScope;
$updateScope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::InstalledPendingReboot;

$computers = $wsus.GetComputerTargets($computerScope);

$computers | foreach-object {
$_.FullDomainName | write-host;
Bu bilginin kaynagi ve scripting hakkinda daha fazla bilgi icin Microsoft Script Center i siddetle tavsiye ederim.

No comments:

Post a Comment