Personal

## Creating an Array with Headers and Columns from a string using [PSCustomObject]

Today, I was updating a script I wrote a while ago, and I wanted to streamline the processing loops once input was received.  This particular script took parameters for:

• Identity (as an email address or UserPrincipalName)
• Target environment type (either Active Directory or Office 365/Azure AD, which return a UserPrincipalName property with Get-ADUser or Get-AzureADUser)

I had gone the “easy” route and just done a simple If/Then to see if the Identity parameter had been passed, and if it had, run a separate chunk of code (which made troubleshooting or updates much harder since I had to keep two branches of the code synced when I made updates).… [ Continue reading ]

Personal

## Basic PowerShell website scraper

Today, I just put together a quick little project for a friend of mine who needed a way to scrape downloadable documents and video files from a website for a project.  Rather than clicking and downloading each one manually, he wondered if there was a way he could do it with a script.… [ Continue reading ]

Information

## Testing a variable with the value of zero

Tonight, while working on my previous script, I ran into an interesting problem when testing the presence of a value.

Consider this:

PS C:\> [int]$IntValue0 = 0 PS C:\> [int]$IntValue1 = 1
PS C:\> [string]$StringValue0 = "0" PS C:\> [string]$StringValue1 = "1"
PS C:\> $IntValue0 0 PS C:\>$IntValue1
1
PS C:\> If ($IntValue0) { "exists" } PS C:\> If ($IntValue1) { "exists" }
exists
PS C:\> if ($StringValue0) { "exists" } exists PS C:\> if ($StringValue1) { "exists" }
exists
PS C:\> if ($IntValue0 -eq$null) { "null" }
PS C:\> if ($IntValue0 -lt 1) {"less than 1" } less than 1 PS C:\>$IntValue0.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Int32 System.ValueType

My short lesson: when setting an integer value to 0, you can’t test for it using If (\$Value), as that will return false. … [ Continue reading ]

Personal

## Update: Create-LabUsers Tool

Just when you thought it couldn’t get more awesome.

It has.

By popular request, I have added a few new features (and fixed an annoyance).  First, the bug fix:

# -Count 1

Yes, it’s true.… [ Continue reading ]

Configuration

## Update to the Create-LabUsers tool – now, with bigger foo

In my quest to make the perfect tool for creating a realistic Lab Environment, I have added yet another feature, based on requests that I imagine people are making but have not yet told me about. … [ Continue reading ]

Configuration

## Update to Create-LabUsers tool

Well, that’s a lie.  I actually had some really great ideas and feedback, so I’ve added a few new features that I wanted to draw attention to:

• Detect existing Exchange session – If you cancel the script to create mailboxes while it’s running, you previously needed to run a Remove-PSSession to close the open Exchange session.
Personal

## Random things with Get-Random

Today’s post is less about anything in particular than it is about jotting a few things down for personal reference.

I learned a couple of things over the last week while developing a tool. I’m sure I learned them once before, but as a person with finite storage and recall capacity, this tidbits were replaced by something I perceived to be of more timely import at the time (such as my kids’ birthday gifts, picking up a suit at the cleaners, a really great Detroit style pizza recipe I’ve finally put the finishing touches on, and how I’ve recently become a fan of grass-fed butter (well, technically butter made from milk produced by grass-fed cows, since you can’t really get butter to eat anything successfully)).… [ Continue reading ]

Information

## Office 365 Administration Inside Out

Hey! It’s finally here! After months of hard work (almost a year from when we started until a copy at my doorstep), we’ve finally made it to the finish line!  Also, pay no mind to my poor cuticles!… [ Continue reading ]

Information

## Office 365 Administration Inside Out

I meant to post this earlier, but I wanted to let everyone know that I’ve had the great honor of being able to write a book with some of the titans of Microsoft Consulting Services.  The book has all new content for Office 365 based on our experience in the field, and even features current service release updates. … [ Continue reading ]