Pagina 1 di 1

Script powershell da sistemare

Inviato: ven giu 23, 2023 4:36 am
da crazy.cat
Lo script in questione permetterebbe di aggiornare le versioni di windows 10, precedenti alla 22h2, all'ultima release.
Ha alcuni prerequisiti:
1. the device has to be on Windows 10
2. The device has to be on major release 2004, 21h1, 21h2, 22h1
3. The device must have the cumulative update of 2022-08 or more recent
Nelle macchine dove ho provato ci sono, ma mi sbatte sempre sul controllo dei prerequisiti e si interrompe.
Lo script originale si trova qui https://success.n-able.com/kb/nable_n-c ... 2h2-update, pensando che fosse un problema di lingua italiana ho provato a tradurne una parte relativa al nome degli aggiornamenti, ma ancora non funziona.
Riuscite a darmi una mano a capire perché non va? :grazie
### THIS SCRIPT WAS CREATED BY MARC-ANDRE TANGUAY, HEAD NERD @ N-ABLE
### While N-able performs initial testing on these scripts, we do not regularly or permanently monitor these scripts, and therefore, we cannot make any guarantees about third-party content. By downloading or using any of these scripts, you agree that they are provided AS IS without warranty of any kind and we expressly disclaim all implied warranties including warranties of merchantability or of fitness for a particular purpose. In no event shall N-able or any other party be liable for any damages arising out of the use of or inability to use these scripts.
### N-able suggests as a best practice that scripts should be tested on non-production environments.
### UPDATED ON : MARCH 24 2023


$proceed=$false
$osversion = Get-WMIObject win32_operatingsystem #| select Caption, Version
$osbuild = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name DisplayVersion).DisplayVersion
if($osversion.caption -like "*Windows 10*")
{
write-host "Windows 10 detected"
"Windows 10 detected"
if($osbuild -eq "21H2" -or $osbuild -eq "2004" -or $osbuild -eq "22H1" -or $osbuild -eq "20H2" -or $osbuild -eq "21H1")
{
write-host "Build of Windows is compatible"
"Build of Windows is compatible"

$objSession = New-Object -com "Microsoft.Update.Session"
$objSearcher = $objSession.CreateUpdateSearcher()
$searchResult = $objSearcher.Search("IsInstalled=0 AND AutoSelectOnWebSites=0 or IsInstalled=0 AND AutoSelectOnWebSites=1 or IsInstalled=1 AND AutoSelectOnWebSites=0 or IsInstalled=1 AND AutoSelectOnWebSites=1 or IsInstalled=0 and DeploymentAction=* or IsInstalled=1 and DeploymentAction=*")
$searchresult.Updates | ft
For ($i=0; $i -lt $searchresult.Updates.Count; $i++) {
$update = $searchResult.Updates.Item($i) # IUpdate object, see WUA API
if($update.isinstalled -eq "True")
{
if($update.title.contains("2023-10 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-09 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-08 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-07 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-06 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-05 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-04 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-03 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-02 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-01 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2022-12 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2022-11 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2022-10 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2022-09 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2022-08 Aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-10 Anteprima aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-09 Anteprima aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-08 Anteprima aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-07 Anteprima aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-06 Anteprima aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-05 Anteprima aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-04 Anteprima aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-03 Anteprima aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-02 Anteprima aggiornamento cumulativo per Windows 10") -or $update.title.contains("2023-01 Anteprima aggiornamento cumulativo per Windows 10") -or $update.title.contains("2022-12 Anteprima aggiornamento cumulativo per Windows 10") -or $update.title.contains("2022-11 Anteprima aggiornamento cumulativo per Windows 10") -or $update.title.contains("2022-10 Anteprima aggiornamento cumulativo per Windows 10") -or $update.title.contains("2022-09 Anteprima aggiornamento cumulativo per Windows 10") -or $update.title.contains("2022-08 Anteprima aggiornamento cumulativo per Windows 10"))
{
write-host "found the required minimum cumulative update so all good - " + $update.title
"found the required minimum cumulative update so all good - " + $update.title
$proceed = $true
}
}
}
if($proceed -eq $false)
{
"the required minimum cumulative update is not installed on this computer, cancelling execution "
}
}
else
{
write-host "Build of Windows is not compatible"
"Build of Windows is not compatible"
$proceed = $False
}
}
else
{
write-host "Windows 10 not detected"
"Windows 10 not detected"
$proceed=$False
}

Re: Script powershell da sistemare

Inviato: ven giu 23, 2023 8:20 am
da CUB3
Quale errore ricevi di preciso?

Re: Script powershell da sistemare

Inviato: ven giu 23, 2023 8:45 am
da crazy.cat
Diceva che non trovava i requisiti necessari, ho capito che è il nome dato alle patch necessarie, devo riuscire ad andare in sede e provarlo perché il test lo devo fare su dei pc aziendali remoti.

Re: Script powershell da sistemare

Inviato: ven giu 23, 2023 9:17 am
da CUB3
Forse sono i nomi contenuti nella stringa di ricerca da convertire?

Codice: Seleziona tutto

$searchResult = $objSearcher.Search("IsInstalled=0 AND AutoSelectOnWebSites=0 or IsInstalled=0 AND AutoSelectOnWebSites=1 or IsInstalled=1 AND AutoSelectOnWebSites=0 or IsInstalled=1 AND AutoSelectOnWebSites=1 or IsInstalled=0 and DeploymentAction=* or IsInstalled=1 and DeploymentAction=*")

Re: Script powershell da sistemare

Inviato: ven giu 23, 2023 10:34 am
da crazy.cat
E' qualcosa legato al nome della patch da cercare "2023-06 Aggiornamento cumulativo per Windows 10 Version 21H2 per i sistemi basati su x64".
Devo riprovarci con più calma dall'ufficio e con un pc davanti agli occhi.
Da casa ho qualche problema.

Re: Script powershell da sistemare

Inviato: sab giu 24, 2023 2:32 am
da crazy.cat
Almeno su un pc sono riuscito a farlo funzionare, prossima settimana seguiranno altri test più approfonditi.

Re: Script powershell da sistemare

Inviato: gio giu 29, 2023 7:08 pm
da crazy.cat
Per chiudere il discorso, se il pc ha un minimo di aggiornamenti di base lo script funziona bene e porta il pc alla 22h2 di windows 10.
Se il pc, come in parecchi casi è fermo al secolo scorso con gli aggiornamenti lo script si blocca.
Comunque soddisfatto.