Uno script in
PowerShell per "risvegliare" gli
Application Pool delle applicazioni
SharePoint:
#url da "svegliare"
# http://www.sgart.it
# elenco delle url da "svegliare"
$urls = @(
"http://sharepoint.sgart.local/"
, "http://sharepoint.sgart.local/_layouts/OSSSearchResults.aspx?k=sgart"
)
#--------------------------------
# esecuzione del risveglio
$urls | % {
$url = $_
$wc = new-object System.Net.WebClient
$wc.Credentials=[System.Net.CredentialCache]::DefaultCredentials
write-host $url
$html = $wc.DownloadString($url)
#anche se alla fine da errore di timeout non è un problema, l'app ormai è stata "svegliata"
write-host "$url end $($html.Length)"
$wc.Dispose()
}
Può essere schedulato tramite lo sheduler di
windows per far ripartire gli Application Pool al mattino oppure, se eseguito ogni tot, per tenerle attive nel caso di uso sporadico.
Giusto per prova una versione multi thread:
# http://www.sgart.it
# elenco delle url da "svegliare"
$urls = @(
"http://sharepoint.sgart.local/"
, "http://sharepoint.sgart.local/_layouts/OSSSearchResults.aspx?k=sgart"
)
#--------------------------------
# esecuzione del risveglio in parallelo e in background
$urls | % {
$job = {
param ($url)
$wc = new-object System.Net.WebClient
$wc.Credentials=[System.Net.CredentialCache]::DefaultCredentials
write-host $url
$html = $wc.DownloadString($url)
#anche se alla fine da errore di timeout non è un problema, l'app ormai è stata "svegliata"
write-host "$url end $($html.Length)"
$wc.Dispose()
}
#| out-null
# lancio il job in background
Start-Job -ScriptBlock $job -ArgumentList $_
}
write-host "Waiting..."
Get-Job | Wait-Job | Receive-Job