Friday fun: Automatically add bookmarks for all current Enterprise Mobility MVP blogs using Powershell

Introduction

This was actually just some random idea I got out of the blue, but if you love learning and love staying current with Configuration Manager and Microsoft Intune, you probably want to follow some of these blogs. You might even have some of them bookmarked already.

This is also for the new and upcoming Configuration Manager / Intune admin. I know when I saw the product for the first time during the SCCM 2007 days, I had no clue where to look for knowledge and who to follow to stay current. This will be a good start. I have gathered all the current Enterprise Mobility MVPs in one place (those who focuses on SCCM / Intune and those who has a blog). They are not all in english though, but Google translate can be used as well.

Also, note that my list also includes a few MVPs who isn’t awarded in the Enterprise Mobility category, but indeed is worth following anyway. Currently the list counts 60 blogs. I intend to keep the list updated and might even expand on the possibilities a bit.

What’s the fuzz?

So, whats the fuzz and how does it work?

First off, I’m by no means any Powershell hero. I just get weird ideas and practice. This is one example. Secondly, the script is free for your disposal. Just copy / paste and save it somewhere as Create-MVPInternetFavorites.ps1 or better yet. Download from here: >> https://gallery.technet.microsoft.com/Automatically-add-5d4ac411

What the script does

  • Retrieve the names  and urls of the blogs online from imab.dk
    • This is based on a list put together manually by me
  • Confirming if the user running the script has the latest version already
    • If the user does, no need to create any favorites this time around
  • If not, loop through each name and url in the lists online and create favorites
  • Create registry keys in HKCU to use for detection method in SCCM (if deployed through SCCM)

In action

##################################################################################################
<#
.SYNOPSIS
    Create Internet Favorites for all current Enterprise Mobility MVPs (those focused on Configuration Manager and Intune) personal blogs/websites.
    Details are taken directly from mvp.microsoft.com. Some profiles are missing out on details and some MVPs simply do not have a blog.
    I do apologies if someone is missing. Please let me know if someone needs to be added.

    The script is originally made out of fun and shall be treated that way. I had the idea and tried my best to carry it out through Powershell.
    Sharing knowledge is key in professional IT and a lot of knowledge is shared on a daily basis on these MVP blogs.
    
    I intend to keep the list up to date.
    Simply re-run script to check for additions.
    The list is retrieved online, as of such an Internet connection is required.

.NOTES
    FileName:    Create-MVPInternetFavorites.ps1
    Author:      Martin Bengtsson
    Created:     21-06-2018
    Version:     1.0
    
#>
###################################################################################################
$Shell = New-Object -ComObject ("WScript.Shell")

# Get content and version for SCCM blogs online from imab.dk
$SCCMBlogurls = try {Invoke-WebRequest "https://imab.dk/mab/SCCM-MVP-Blogs.txt" -Headers @{"Cache-Control"="no-cache"} -Method POST} catch {Write-Host -ForegroundColor Red "Cannot retrieve blog urls" ; break}
$FavoritesVersion = try {Invoke-WebRequest "https://imab.dk/mab/MVP-FavoritesVersion.txt" -Headers @{"Cache-Control"="no-cache"} -Method POST} catch {Write-Host -ForegroundColor Red "Cannot retrieve favorites version" ; break}
$SCCMBlogurls = $SCCMBlogurls.Content
$FavoritesVersion = $FavoritesVersion.Content

# Convert to Array
$SCCMBlogurlsArray = $SCCMBlogurls -split "`r`n"

# Get current date
$Today = (Get-Date).ToString("dd/MM/yyyy")

# Set Favorites folders
$FavoritesFolder = "$env:USERPROFILE\Favorites"
$SCCMMVPFolder = "SCCM MVP Blogs"

# try retrieve install status and version from registry
try {
    try { Clear-Variable -Name MVPFavoritesInstalled -ErrorAction SilentlyContinue
          Clear-Variable -Name InstalledVersionValue -ErrorAction SilentlyContinue } catch { "catch" }
    
    $InstallPath = "HKCU:\SOFTWARE\MVPFavorites"
    if (Test-Path -Path $InstallPath) {
        # Retrieving installation status and version
        $MVPFavoritesInstalled = Get-ItemProperty -Path $InstallPath -Name "MVPFavoritesInstalled"
        $InstalledVersionValue = Get-ItemProperty -Path $InstallPath -Name "MVPFavoritesVersion"
    }
}
catch { "catch" }

# Determine if an installation or update is needed
if (($MVPFavoritesInstalled.MVPFavoritesInstalled -eq "1") -and ($InstalledVersionValue.MVPFavoritesVersion -eq $FavoritesVersion)){
    
    # nothing to see here - already have the latest bunch favorites installed
    Write-Host -ForegroundColor Red "Breaking - content match"
    break
}

# clear errors from try catch blocks
$error.clear()

# Loop trough the array and create new favorite for each
foreach ($MVP in $SCCMBlogurlsArray) {
    
    $MVP = $MVP -split(',')
    $Name = $MVP[0]
    $URL = $MVP[1]

    if (($URL) -and ($Name)) {
        
        try {
            if (-not(Test-Path -Path "$FavoritesFolder\$SCCMMVPFolder")){
                New-Item -ItemType Directory -Path "$FavoritesFolder\$SCCMMVPFolder"}
            $Favorite = $Shell.CreateShortcut($FavoritesFolder + "\$SCCMMVPFolder\$Name" + ".url")
            $Favorite.TargetPath = "$URL";
            $Favorite.Save()
        }
        catch { }      

    }
}

# Write to registry if everything works as expected
if (!$error) {

    # Create registry key path if not exist
    $RegistryPath = "HKCU:\Software\MVPFavorites"
    if (-not(Test-Path -Path $RegistryPath)) {
        New-Item -Path $RegistryPath –Force
        }
    # Create the registry key used as detection method in the application in SCCM
    New-ItemProperty -Path $RegistryPath -Name "MVPFavoritesInstalled" -Value 1 -PropertyType STRING -Force
    New-ItemProperty -Path $RegistryPath -Name "MVPFavoritesDate" -Value $Today -PropertyType STRING -Force
    New-ItemProperty -Path $RegistryPath -Name "MVPFavoritesVersion" -Value $FavoritesVersion -PropertyType STRING -Force

}
else {
}

 

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.