Question
Installation silencieuse wsus par powershell
- Cedric
- Auteur du sujet
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 7
- Remerciements reçus 0
il y a 14 ans 3 mois #10813
par Cedric
Installation silencieuse wsus par powershell a été créé par Cedric
Bonjour à tous,
Utilisant powershell depuis quelques temps, j'aurais besoin de vos lumières si possible.
J'ai un script qui me permet d'installer une mise à jour spécifique (dans mon cas, la maj SP1) en passant par windows update. Le script fonctionne correctement, j'aurais juste voulu savoir s'il n'y a possibilité de l'installer silencieusement.
Je m'explique, mon script recherche la MAJ, la télécharge, l'installe et redémarre (parfait jusque la). Mais à la première ouverture de session, une fenêtre s'affiche \"Le service pack 1 de windows a été installé\" mais je souhaiterai qu'elle ne s'affiche pas (d'où la solution de l'installer en silencieux, malheureusement, je ne trouve pas ou mettre l'argument ni comment...) sachant que cela se fait à partir d'une collection.
Je sais pas si c'est très clair, si vous avez besoin de précisions, n'hésitez pas à me demander
Je vous joins le code
Merci d'avance de vos réponses
[code:1]
# INSTALLATION DU SERVICE PACK 1 DE WINDOWS 7 PAR WINDOWS UPDATE
#LISTE DES ERREURS
#Exit 0 = OK
#Exit 2 = Catch error
#Exit 3 = KB Not found
#Exit 4 = Download problem
#Exit 5 = Install problem
Try
{
#Create session object
$objSession = New-Object -ComObject \"Microsoft.Update.Session\"
$objSearcher = $objSession.CreateUpdateSearcher()
#check source of updates
#Create object searcher
$objSearch = $objSearcher.Search(\"IsInstalled=0\"«»)
#Searching update corresponding to KB specified
Foreach($Update in $objSearch.Updates)
{
If ($Update.Title -like \"*976932*\"«»)
{
$Updatetitle = $Update.Title
#Create update collection
$objCollectionTmp = New-Object -ComObject \"Microsoft.Update.UpdateColl\"
$objCollectionTmp.Add($Update) | Out-Null
#Create downnloader object
$objDownloader = $objSession.CreateUpdateDownloader()
$objDownloader.Updates = $objCollectionTmp
#Download update collection
$objDownloadResult = $objDownloader.Download()
$Downloadresultcode = $objDownloadResult.resultcode
#0 { $Status = \"NotStarted\"}
#1 { $Status = \"InProgress\"}
#2 { $Status = \"Downloaded\"}
#3 { $Status = \"DownloadedWithErrors\"}
#4 { $Status = \"Failed\"}
#5 { $Status = \"Aborted\"}
If ($objDownloadResult.resultcode -eq 2)
{
#Create installer object
$objInstaller = $objSession.CreateUpdateInstaller()
$objInstaller.Updates = $objCollectionTmp
#Install update collection
$objInstallResult = $objInstaller.Install()
#0 { $Status = \"NotStarted\"}
#1 { $Status = \"InProgress\"}
#2 { $Status = \"Installed\"}
#3 { $Status = \"InstalledWithErrors\"}
#4 { $Status = \"Failed\"}
#5 { $Status = \"Aborted\"}
If ($objInstallResult.ResultCode -eq 2)
{
#If install ok
Exit 0
}
Else
{
#If problem install
exit 5
}
}
Else
{
#If problem download
Exit 4
}
}
Else
{
#If KB not found
$returncode = 2
}
}
If ($returncode -eq 2)
{
# Exitcode if KB not found
Exit 3
}
}
catch
{
Exit 2
}
[/code:1]
Utilisant powershell depuis quelques temps, j'aurais besoin de vos lumières si possible.
J'ai un script qui me permet d'installer une mise à jour spécifique (dans mon cas, la maj SP1) en passant par windows update. Le script fonctionne correctement, j'aurais juste voulu savoir s'il n'y a possibilité de l'installer silencieusement.
Je m'explique, mon script recherche la MAJ, la télécharge, l'installe et redémarre (parfait jusque la). Mais à la première ouverture de session, une fenêtre s'affiche \"Le service pack 1 de windows a été installé\" mais je souhaiterai qu'elle ne s'affiche pas (d'où la solution de l'installer en silencieux, malheureusement, je ne trouve pas ou mettre l'argument ni comment...) sachant que cela se fait à partir d'une collection.
Je sais pas si c'est très clair, si vous avez besoin de précisions, n'hésitez pas à me demander
Je vous joins le code
Merci d'avance de vos réponses
[code:1]
# INSTALLATION DU SERVICE PACK 1 DE WINDOWS 7 PAR WINDOWS UPDATE
#LISTE DES ERREURS
#Exit 0 = OK
#Exit 2 = Catch error
#Exit 3 = KB Not found
#Exit 4 = Download problem
#Exit 5 = Install problem
Try
{
#Create session object
$objSession = New-Object -ComObject \"Microsoft.Update.Session\"
$objSearcher = $objSession.CreateUpdateSearcher()
#check source of updates
#Create object searcher
$objSearch = $objSearcher.Search(\"IsInstalled=0\"«»)
#Searching update corresponding to KB specified
Foreach($Update in $objSearch.Updates)
{
If ($Update.Title -like \"*976932*\"«»)
{
$Updatetitle = $Update.Title
#Create update collection
$objCollectionTmp = New-Object -ComObject \"Microsoft.Update.UpdateColl\"
$objCollectionTmp.Add($Update) | Out-Null
#Create downnloader object
$objDownloader = $objSession.CreateUpdateDownloader()
$objDownloader.Updates = $objCollectionTmp
#Download update collection
$objDownloadResult = $objDownloader.Download()
$Downloadresultcode = $objDownloadResult.resultcode
#0 { $Status = \"NotStarted\"}
#1 { $Status = \"InProgress\"}
#2 { $Status = \"Downloaded\"}
#3 { $Status = \"DownloadedWithErrors\"}
#4 { $Status = \"Failed\"}
#5 { $Status = \"Aborted\"}
If ($objDownloadResult.resultcode -eq 2)
{
#Create installer object
$objInstaller = $objSession.CreateUpdateInstaller()
$objInstaller.Updates = $objCollectionTmp
#Install update collection
$objInstallResult = $objInstaller.Install()
#0 { $Status = \"NotStarted\"}
#1 { $Status = \"InProgress\"}
#2 { $Status = \"Installed\"}
#3 { $Status = \"InstalledWithErrors\"}
#4 { $Status = \"Failed\"}
#5 { $Status = \"Aborted\"}
If ($objInstallResult.ResultCode -eq 2)
{
#If install ok
Exit 0
}
Else
{
#If problem install
exit 5
}
}
Else
{
#If problem download
Exit 4
}
}
Else
{
#If KB not found
$returncode = 2
}
}
If ($returncode -eq 2)
{
# Exitcode if KB not found
Exit 3
}
}
catch
{
Exit 2
}
[/code:1]
Connexion ou Créer un compte pour participer à la conversation.
- Arnaud Petitjean
-
- Hors Ligne
- Modérateur
-
il y a 14 ans 3 mois #10828
par Arnaud Petitjean
MVP PowerShell et créateur de ce magnifique forum
Auteur de 6 livres PowerShell aux éditions ENI
Fondateur de la société Start-Scripting
Besoin d'une formation PowerShell ?
Réponse de Arnaud Petitjean sur le sujet Re:Installation silencieuse wsus par powershell
Salut !
Je ne suis pas sur que PowerShell va t'etre d'une grande aide sur ce coup la. Si ce n'est que tu vas devoir sans doute mettre a jour la base de registre de ta machine pour eviter l'affichage du pop-up.
Maintenant ton defi est de trouver la bonne cle de registres, le reste est du gateau...
Arnaud
Je ne suis pas sur que PowerShell va t'etre d'une grande aide sur ce coup la. Si ce n'est que tu vas devoir sans doute mettre a jour la base de registre de ta machine pour eviter l'affichage du pop-up.
Maintenant ton defi est de trouver la bonne cle de registres, le reste est du gateau...
Arnaud
MVP PowerShell et créateur de ce magnifique forum
Auteur de 6 livres PowerShell aux éditions ENI
Fondateur de la société Start-Scripting
Besoin d'une formation PowerShell ?
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.038 secondes
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les débutants
- Installation silencieuse wsus par powershell