Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # sledgehammer\bin\awmsdc.ps1
- $get_ms_defcon={ # start of script block
- Param ($divider, $errmsg)
- $msg=$errmsg
- $progressPreference="silentlyContinue"
- If (test-netconnection www.askwoody.com http -InformationLevel Quiet){# not supported by windows 7
- Try{$WebResponse=Invoke-WebRequest "https://www.askwoody.com"}Catch{$WebResponse=""}
- If ($WebResponse.Statuscode -eq 200)
- {ForEach ($Image in $WebResponse.Images){$x=$Image.OuterHTML.ToString()
- If($x -like '*MS-DEFCON-*'){
- $msg="`r`n MS-DEFCON = "+$x.split('/')[8].split('.')[0].SubString(10,1) + "`r`n`r`n" + `
- "$divider`r`n`r`n" + `
- "MS-DEFCON 1: Current Microsoft patches are causing havoc. Don't patch.`r`n`r`n" + `
- "MS-DEFCON 2: Patch reliability is unclear. Unless you have an immediate, pressing need`r`n" + `
- " to install a specific patch, don't do it.`r`n`r`n" + `
- "MS-DEFCON 3: Patch reliability is unclear, but widespread attacks make patching prudent.`r`n" + `
- " Go ahead and patch, but watch out for potential problems.`r`n`r`n" + `
- "MS-DEFCON 4: There are isolated problems with current patches, but they are well-known`r`n" + `
- " and documented here. Check this site to see if you're affected and if`r`n" + `
- " things look OK, go ahead and patch.`r`n`r`n" + `
- "MS-DEFCON 5: All's clear. Patch while it's safe.`r`n`r`n" + `
- "$divider`r`n`r`n" + `
- "More info at https://www.askwoody.com`r`n`r`n" + `
- "$divider`r`n"
- Break
- }}}}
- $msg
- } # end of script block
- #
- $divider=":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
- $errmsg="`r`nUnable to retrieve MS-DEFCON rating from askwoody.com"
- $timeout=10 # timeout value in seconds
- $retry=3 # max number of retry count if request timed out
- <#
- :::::::::::::::::::::::::
- Internet connection check
- #>
- Clear-Host
- If(![Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet){
- "`r`n`r`n`r`n`r`n"
- " Internet connection test failed.`r`n`r`n"
- " Microsoft Store or Windows Updates won't work without Internet.`r`n`r`n`r`n"
- "$divider`r`n`r`n`r`n"
- " --->>> Press ""Enter"" to continue if you're sure Internet is working.`r`n`r`n`r`n"
- "$divider`r`n`r`n`r`n"
- " It's safe to cancel now if needed. Your system will not be left in an unstable state.`r`n`r`n"
- " (Ctrl-C, Alt-F4, or click ""X"" to cancel and exit)`r`n"
- $return=Read-Host
- Clear-Host
- Exit # exit if no Internet connection ===> don't get MS-Defcon from askwoody.com
- }
- <#
- :::::::::::::::::::::::::::::::
- Get MS-Defcon from askwoody.com
- #>
- "Sledgehammer is attempting to retrieve MS-DEFCON rating from askwoody.com..."
- For($r=1; $r -le $retry; $r++){
- $job=start-job -ScriptBlock $get_ms_defcon -ArgumentList $divider, $errmsg
- $t=0;While($job.state -ne "Completed" -and $t -ne $timeout){start-sleep 1;$t++}
- Clear-Host
- If($t -ne $timeout){
- #"Answer returned after $t s - timeout value : $timeout s - retry count : $r"
- Receive-Job $job
- Exit
- }
- }
- #"No answer returned after waiting $timeout seconds $retry times"
- $errmsg
Advertisement
Add Comment
Please, Sign In to add comment