Skip to content

Instantly share code, notes, and snippets.

@darrenjrobinson
Last active December 22, 2018 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenjrobinson/7dd6e79a0b805fdecfc6dfc640fca247 to your computer and use it in GitHub Desktop.
Save darrenjrobinson/7dd6e79a0b805fdecfc6dfc640fca247 to your computer and use it in GitHub Desktop.
# Install the Microsoft MVP PowerShell Module
# Install-Module -name MVP
Import-Module -Name MVP
# my Subscription Key obtained from https://mvpapi.portal.azure-api.net/
$subkey = '12345669b3c459bb2c11da79567890'
# AuthN to MVP API
Set-MVPConfiguration -SubscriptionKey $subkey
# Get the last Blog Post
$wordpressBlogURL = 'https://public-api.wordpress.com/rest/v1/sites/<yourwordpressURL>/posts/?number=1'
$BlogPostData = Invoke-RestMethod -uri $wordpressBlogURL
# Static because it is obviously a Blog Post
$contributionType = "Blog Site Posts"
# Static as that is my MVP Category
$contributionTechnology = "Identity and Access"
# URL
$contributionURL = $BlogPostData.posts.URL
# Title
$contributionTitle = $BlogPostData.posts.title
# Description
$descriptionHTML = $BlogPostData.posts.excerpt
# Remove HTML Formatting
$contributionDescription = $descriptionHTML -replace '<[^>]+>',''
# Translate Date Format
$date = $BlogPostData.posts.date
$arrDate = $date.Split("T")
$contributionDate = $arrDate[0].Replace("-","/")
# Submit latest Blog Post to MVP Community Contributions Profile
try {
write-host "Submitting your Blog Post titled $($contributionTitle) you wrote on $($contributionDate) to $($contributionTechnology)"
New-MVPContribution -StartDate $contributionDate `
-ContributionTechnology $contributionTechnology `
-ContributionType $contributionType `
-Title $contributionTitle `
-Description $contributionDescription `
-ReferenceUrl $contributionURL `
-Visibility EveryOne } catch {
write-host "Well that was unexpected. Check your last post for anomolies."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment