Quickly get machine model, BIOS version and serial number/ service tag

I knocked this up just to make it easier to get the model, BIOS versions and serial numbers/ service tags (only tested against Dell machines so far). I haven’t commented it because hopefully the variable names are evident enough.

$computerDetails=Get-WmiObject -Class Win32_ComputerSystem
$BIOSDetails=Get-WmiObject -Class Win32_BIOS
Clear-Host
Write-Host “The model is” $computerDetails.Manufacturer,$computerDetails.Model
Write-Host “With BIOS version” $BIOSDetails.SMBIOSBIOSVersion “and Serial number” $BIOSDetails.SerialNumber

Advertisements

PowerShell Invoke-WebRequest

After (taking some time) to discover the Invoke-WebRequest cmdlet in PowerShell 3, I hoped it might at least be able to warn me when the bane of IT- Adobe and Java updates- were updated, so I knocked up the following script. Hopefully you’ll find it sufficiently well commented, but essentially it extracts a URI from the main Adobe Reader download site, checks it against an initially non-existent file with an existing URI inside it, then continually updates that file and re-checks to find out when a new version is available. It also keeps a legacy list of versions on file.

One word of warning- I can’t get PowerShell to authenticate through our proxy, so I’ve only used it with straight-through connections to the internet.

Also, I haven’t tested it for real- there are a couple of dummy lines in the script that I’ve used to mimic the updating process but I guess I’ll have to wait for Adobe to actually release a new version. However it all works functionally, including the email bit. I haven’t scheduled it either, which is the main point of writing it.

I do have modified version that run against Air (easy), Java (harder, x86 only) and Shockwave (just weird- it works but will only allow me to install the update, not save it). I haven’t done Flash yet because I was working on a Windows 8 machine, which has its Flash updates sorted through Windows Updates.

I know- working within an IT department- that Adobe do allow you to register for distribution rights which would have probably made the whole thing easier, but it contravenes the license terms to publish those URIs here…

————————————————————————————
#This script will monitor the primary Adobe Reader download site and send an email when new version are available
#This script will indicate that Adobe reader is out-of-date the first time it is run;
#this is because the relevant text files aren’t populated; ignore and re-run, then it should be correct

#Oh; and it doesn’t work through our proxy, despite trying New-PSSessionOption -ProxyAccessType with all combinations of -ProxyAuthentication

#Start by clearing the window
Clear-Host

#Explicitly defines legacy Adobe version variable as string
[string]$savedReaderDownloadSite

#Explicitly defines current Adobe download page variable as string, sets to value of Windows x86 download link
[String]$readerDownloadNowSite=(Invoke-WebRequest -Uri http://get.adobe.com/uk/reader).Links|Select-String -Pattern “Download Now”

#Explicitly defines actual (direct) download link as string, sets to single value
[string]$actualReaderDownloadSite=$readerDownloadNowSite.Split(‘; ‘)|Select-String -Pattern “href=/”

#These are dummy lines. The URI is real, but if you comment out the 2 [string] declarations above and un-comment these,
#you can test the script with dummy values to make sure it works. Start with 9.5, then replace that number with 10.1.4,
#then eventually comment these 2 lines back out and un-comment the 2 [string] declarations above.
#[string]$readerDownloadNowSite=”href=/uk/reader/completion/?installer=Reader_9.5_English_UK_for_Windows}”
#[string]$actualReaderDownloadSite=$readerDownloadNowSite.Split(‘; ‘)|Select-String -Pattern “href=/”

#Next 2 lines trim unwanted characters to leave “clean” http URI
$actualReaderDownloadSite=$actualReaderDownloadSite.TrimStart(“href=”)
$actualReaderDownloadSite=$actualReaderDownloadSite.TrimEnd(“}”)

#This line prefixes a URI to the $actualReaderDownloadSite
$actualReaderDownloadSite=$actualReaderDownloadSite.Insert(0,”http://get.adobe.com”)

#Reads the existing version of Adobe Reader into a variable
$savedReaderDownloadSite=Get-Content C:\Support\Scripts\Web\Adobe\currentAdobeReaderVersion.txt

#Checks to see if the existing version of Adobe Reader is the same as the existing- stored- version
#If it is, write a message to the PowerShell window
If($savedReaderDownloadSite -eq $actualReaderDownloadSite)
{
Clear-Host
Write-Host “Adobe Reader is up-to-date.”
}

#If the two versions don’t match, send an email!
#It also logs the existing version to a “legacy version” text file, so you have a record of all Adobe Reader versions
ElseIf($savedReaderDownloadSite -ne $actualReaderDownloadSite)
{
Clear-Host
$savedReaderDownloadSite|Add-Content C:\Support\Scripts\Web\Adobe\legacyAdobeReaderVersion.txt

#Define hub transport server, sender and recipient variables

$smtp_server = “mailserver.emaildomain.com”
$sender = “FirstName Surname <firstname.surname@emaildomain.com>”
$recipient = “FirstName Surname <firstname.surname@emaildomain.com>”

#Define date and time variables

$dateNow = get-date -displayhint date

#Define email subject and body

$msg_subject = “Adobe Reader is out-of-date”
$msg_body_text = “Adobe reader is out-of-date on the $dateNow `n You can download it from $actualReaderDownloadSite”

#Send it

Send-MailMessage -to $recipient -from $sender -subject $msg_subject -body $msg_body_text -smtpserver $smtp_server

}

#Clears the contents of the existing version file.
#This will always fail first time, as the file does not yet exist
Clear-Content C:\Support\Scripts\Web\Adobe\currentAdobeReaderVersion.txt

#Writes the new version of Adobe Reader to the above file (or creates it first time around).
$actualReaderDownloadSite|Add-Content C:\Support\Scripts\Web\Adobe\currentAdobeReaderVersion.txt

Deploying Apple QuickTime 7.74.80.86 with SCCM 2012 SP1 CU2

Yet again, I’ve encountered a really strange error (bearing in mind this is an entirely test CM set-up I’ve got going). I had a few packages- Java 7-25 (both bit-versions), Office 2012 ProPlus and Quicktime. After this mornings outing, I was pretty happy- I could install Java repeatedly, and (due to an accident) re-built my Office install from scratch and it worked first time. But QuickTime wouldn’t play ball- I kept getting “The software change returned error code 0x643 (1603)”. Neither Bing nor Google were much help, so I was on the verge of giving up when- rather obviously- I spotted on some website about starting at the start and trying to install QuickTime manually on the PC. So I did this, and immediately got some spiel about there being a newer version of QuickTime installed. Now I knew this was wrong because (a) I’d just downloaded the installer this morning, so it was unlikely Apple had released another version and (b) QuickTime wasn’t installed, because Add/ Remove programs didn’t list it.

After stripping most of the QuickTime entries from the Registry (just obvious program-centric ones, I ignored anything to do with media type files using QuickTime) I retried using SCCM to push the QuickTime.msi file and that also failed. I re-stripped the Registry, created an SCCM package (not application) using the QuickTimeInstaller.exe file and it worked. I have no idea where all those Registry entries came from, I can only guess that my test PC was so messed up from having stuff installed and uninstalled that it’s corrupted.

Deploying Office 2013 with SCCM 2012 SP1 CU2

After (metaphorically) banging my head against a brick wall for some time, I’ve finally got Office 2013 installed (on-demand) as per this guide (which is excellent):

http://www.ronnipedersen.com/2012/11/how-to-deploying-microsoft-office-2013-using-configmgr-2012/

I’d tried using this guide over and over again with no success. My clients CAS log was reporting 0 distribution points, and the Software Center was either saying that the installation failed (with various error codes, one of which was 0x87d00607) or that the software couldn’t be found on any servers. The server side was just reporting that Distribution Manager couldn’t find or create… blah blah blah. I think you get the message. Anyway, at various points of searching I found- in sequence- these two pages:

http://blog.msvconsultancy.co.uk/2013/01/system-center-configuration-manager-2012-sp1-distribution-point-bug/

http://www.windows-noob.com/forums/index.php?/topic/7199-help-big-issue-with-primary-dp-after-updating-to-sp1/

Which both basically refer to

http://social.technet.microsoft.com/Forums/en-US/8e860651-4288-42c1-b04f-c6ac72dd02f1/help-big-issue-with-primary-dp-after-updating-to-sp1

The irritating thing is, I’d tried this suggestion from msvconsultancy.co.uk and it hadn’t worked because I hadn’t tied everything together. After finally (re-)finding the same info at windows-noob.com I re-configured the Site System Installation account properties, deleted the distribution point from the application, re-distributed it and then it worked very, very quickly- I think Office was installed in about 5 minutes. So a big thanks to Ronni Pedersen and Ben Kellermann for their joint effort at sorting out my Office 2013 deployment issues (I hadn’t followed Ronni’s blog exactly as I’d skipped the “Requirements” bits- I just wanted to get Office installed on a test Hyper-V machine so wasn’t that bothered about providing conditions). Ben Kellerman’s post is particularly helpful as presumably I’d have encountered these errors regardless of which program I was distributing.