Very slick SCCM/SQL Reporting Service Dashboard

Aside Posted on

Saw this today on the SCCM Mailing list. Very, very nice looking dashboard report which pulls data from SCCM to display an at-a-glance dashboard view of the health of System Center Configuration Manager.

Very cool!
Very cool!

http://thatsystemcenterguy.wordpress.com/2014/10/29/sccm-dashboards/

A primer on Docker from the Windows Perspective

Posted on Updated on

If you’re keeping up with the Azure talks from TechEd Barcelona this week (and you should be!) you’ve heard a lot of mentions about Docker recently.

Wondering what it is?

Docker is a technology that allows an application developer to install and sequence the execution of their application to ‘containerize’ it in a portable container which can be docked and executed anywhere, seamlessly alongside other applications without application installation dependencies causing interference. The key differentiation point here is that the application and its dependencies are virtualized, rather than the underlying OS, as in traditional virtualization. The big benefit to abstraction of the OS is portability and a significant reduction in overhead.

Instead of developers giving out an install script and binaries, they can provide a fully configured Docker image, which can be run on any system with the Docker engine installed, which includes OS X, Windows and pretty much any version of Linux. Keep in mind while running Docker in Windows that while VirtualBox will be used, Docker does not require hardware virtualization support.

Read the rest of this entry »

Use Invoke-WebRequest to get your physical location

Posted on Updated on

Hi all,

This is predominantly going to be a script sharing post.   I’ve got a fever for these APIs so expect to see me crank out a bunch of new cmdlettes in the next coming weeks.  I’ve already got one for finding a restaurant in your area using an awesome opentable-scraping API I found on heroku.  Anyway…send me requests, this is soo much fun!

Unlike my previous post, this API is totally free, so you can copy and paste and start using this code today!  Why did I want to do this?  Well in a conversation with a fellow redditor about a way to get Weather Info, he wondered how to do a GPS or geolocation lookup within the script, to have it update as he moved around.

I naturally had to see what I could do!

Read the rest of this entry »

Help your peers shine! Nominations for PowerShell Heroes are open

Aside Posted on

Do you know someone who has been helping the community, active on the forums, or otherwise kicking PowerShell butt and hasn’t been nominated for an MVP or other award?

PowerShell.org is rolling out their second round of nominations for PowerShell heroes.  Big congrats to Mark Schill and Francois Xavier Cat, both of whom I’ve spoken with and are well known around PowerShell circles!

Nominations are availble here: http://powershell.org/wp/2014/10/07/accepting-nominations-for-2015-powershell-heroes/

Get the daily forecast in your console, with PowerShell

Posted on Updated on

Today I saw a post on reddit about scraping a webpage for weather information. Reading over the comments, I had an idea, and I quickly looked away wanting to try this myself before seeing what someone else posted.

http://www.reddit.com/r/PowerShell/comments/2jitvn/help_with_screen_scraping_or_interpreting_web/

If you don’t care about how this is done, skip to the bottom for the code, here is a preview of the finished product:

weather_00
Read the rest of this entry »

Download all the PowerShell summit videos…with PowerShell

Aside Posted on

This is just a rehash of a previous post of using YoutubeDL to parse playlists and download stuff, but here is doing it to download the European PowerShell Summit Videos.

$url = "https://www.youtube.com/playlist?list=PLfeA8kIs7Coehjg9cB6foPjBojLHYQGb_"

$playlisturl = $url

$VideoUrls= (invoke-WebRequest -uri $Playlisturl).Links | ? {$_.HREF -like "/watch*"} |  `
? innerText -notmatch ".[0-9]:[0-9]." | ? {$_.innerText.Length -gt 3} | Select innerText, `
@{Name="URL";Expression={'http://www.youtube.com' + $_.href}} | ? innerText -notlike "*Play all*" | ? innerText -notlike "*Play*"

ForEach ($video in $VideoUrls){
    Write-Host ("Downloading " + $video.innerText)
    .\youtube-dl.exe $video.URL
    }

Useful PowerShell ISE Snippets

Posted on

Hi guys,

One of the best features of the PowerShell ISE is the presence of Snippets, a great engine to fill in code-snippets for common tasks.  I pretty much use this every single day!

Snippets0Negative1
Hit Control+J to display the snippet menu. You can hover over for more info and detailed syntax.

 

Making a new Snippet is kind of difficult though.  I found this wonderful little snippet that allows you to easily create more snippets.  I know.  Snippets in Snippets?  Not sure if it is more Ludacris or Inception though…

Rob the PowerShell DBA had this awesome snippet on his blog.

$snippet1 = @{
    Title = "New-Snippet";
    Description = "Create a New Snippet";
    Text = @"
`$snippet = @{
    Title = `"Put Title Here`";
    Description = `"Description Here`";
    Text = @`"
    Code in Here 
`"@
}
New-IseSnippet @snippet
"@
}
New-IseSnippet @snippet1 –Force

From <http://sqldbawithabeard.com/2014/09/09/powershell-snippets-a-great-learning-tool/>

What does it do? Well, after running this in the ISE, you can hit Control+J and bam, an easy to fill in form to create a nice new Snippet.

Snippets00
You’ll use this on a weekly basis!

Fill in the values and hit F5 to create the snippet.

I love this so much, here are a bunch of snippets I use everywhere.

Custom Objects using Try/Catch

I made a whole blog post about doing this. It’s now my go-to standard when making information gathering tools.

$snippet = @{
    Title = "Try/Catch/Custom Objects";
    Description = "A great way to get good streamlined output while Try/Catching";
    Text = @"
        try {`$a=Get-WmiObject -Class Win32_ComputerSystem -ErrorAction Stop -ComputerName $name} 
   catch{`$a= [pscustomobject]@{Name=`$name;Domain="Access Denied"}}
   [pscustomobject]@{RUM_Name=`$name;ReplyName=`$a.Name;Domain=`$a.Domain} 
"@
}
New-IseSnippet @snippet

Quick PS Custom Object

Sometimes you just need to grab a bunch of info about a thing and make it a single object. Here’s how:

$snippet = @{
    Title = "Custom Object";
    Description = "I always forget how to do this!";
    Text = @"
       #Add more columns to the object by adding extra key/values
      [pscustomobject]@{Name=$name;Domain="Access Denied"}
"@
}

New-IseSnippet @snippet

Progress Bar within ForEach Loop

This looks easy but I would forget how to do it constantly.

$snippet = @{
    Title = "Write Progress Sample";
    Description = "Progress and how to do it";
    Text = @"
    #sample range of numbers
    `$users = (1..13000)

    #setting up base number
    `$i=0
    
    ForEach (`$user in `$users){
        #increment
        `$i++ 

        #Round the numbers up for a nice output and then Write-Progress
        Write-Progress -Activity "Processing `$user" -PercentComplete ((`$i/`$users.Count) * 100) -Status ("`$i out of " + `$users.Count +" completed "+[math]::Round(((`$i/`$users.Count) * 100),2) +" %")
        }
"@
}
New-IseSnippet @snippet

PowerShell V1 Custom Object Format

Sometimes you have to work on ancient systems and forget how to make old-school custom objects. Never again! This example is based on capturing the output of Get-MailboxStatistics within $mbx.

 $snippet = @{
       Title = "PS 2.0 Custom Objects";
       Description = "Old Fashioned Custom Objects";
       Text = @"
       `$ObjectProperties = @{
Name = `$user
RecipientType=`$mbx.RecipientType
LastLoggedOnUserAccount=`$mbxstat.LastLoggedOnUserAccount
LastLogOffTime=`$mbxstat.LastLogOffTime
LastLogonTime=`$mbxstat.LastLogonTime
}
`$obj = New-Object PSObject -Property `$ObjectProperties

"@
   }
   New-IseSnippet @snippet

Old-School Custom Objects using Try/Catch

A repeat of my first Custom Object loop, this time with Pre-V2 objects

$snippet = @{
    Title = "Old School try/catch custom object ";
    Description = "Using try/catch to create custom objects is a great way to capture information succinctly.  However, the [PSCustomObject] Accelerator/casting only work on PS 3 and up.  This example uses old school Items to get around that";
    Text = @"
    `$users | ForEach-Object { 
    `$name = `$_
    try {`$a=Get-mailbox `$name -erroraction Stop} 
   catch{   `$ObjectProperties = @{
        Name = `$name
        HiddenFromAddressListsEnabled="MBX Not Found"
        }
        `$a = New-Object PSObject -Property `$ObjectProperties}


       `$ObjectProperties = @{
            Name = `$name
            HiddenFromAddressListsEnabled=`$a.HiddenFromAddressListsEnabled
            }
        New-Object PSObject -Property `$ObjectProperties
   }
"@
}
New-IseSnippet @snippet

Display a Popup Prompt

This is a shorty, but a useful one!

$snippet = @{
    Title = "Popup Message";
    Description = "Add a simple pop-up message";
    Text = @"
    `$msg = New-Object -ComObject WScript.Shell
    `$msg.Popup("Hi Chris", 5, "DeadMau5", 48)

"@
}
New-IseSnippet @snippet