Fun & Frolics: Generate a 0 and 1 Screen Stream

What a ridiculous title! Believe me, the post gets even more ridiculous. Anyway, it’s a bit of fun!   I had to do the following for a conference I recently spoke at…   function ExfiltrateData { Write-Output ” ” 1..900 | % {Write-Host “$(Get-Random -Minimum 0 -Maximum 2)” -NoNewline } 1..14 | % {Write-Host “$(Get-Random…

0

Module Manifest – ScriptsToProcess

Here’s a nice little trick. When creating a PowerShell module you can specify a list of scripts to process when the module is loaded. You can use the scripts for validation or prerequisite checking. Here’s a nice little example… In the .psd1* file for the module, i.e. the manifest, add (or uncomment) a line to look…

0

Start-AzureCloudService

Here’s a function I use quite a lot. Now, I know it’s old-world (ASM rather than ARM) in terms of Azure, but I still have a lot of old-world, cloud services. In fact, a lot of them were built by the following script and the function should be considered as partner code.   Build an…

0

Security Focus: Get Mail Enabled Admin Users

Browsing the internet with an admin account is a very, very bad thing to do. Using an admin account to send / receive email is also a very, very bad thing. Why? Well you expose the credentials to a high risk of being stolen and used to compromise your enterprise. Want do to some checks against Active…

1

Try to Catch Error Exception Types

When error handling with Try, Catch, Finally you can create conditional catch statements to target specific exceptions. Here’s an example.   try { $wc = new-object System.Net.WebClient $wc.DownloadFile(“http://www.contoso.com/MyDoc.doc”) } catch [System.Net.WebException],[System.IO.IOException] { “Unable to download MyDoc.doc from http://www.contoso.com. } catch { “An error occurred that could not be resolved.” }   Look at the first…

1

Back to Basics: Generate Monthly Report Folders

I’m always using PowerShell to just, well, help out with day to day stuff I have to do. The other week I used PowerShell to generate a bunch of folders for 2017 that I’ll use to store my expense receipts in. All very mundane; all completed in milliseconds. $a = 1..12 | % {(Get-Date -Month $_ -f…

0

Security Focus: Enable / Disable MFA on Azure AD Admin Account

Last week I presented a little function that I use to reset my Azure AD admin account passwords. This week I want to show how to enable / disable Multi Factor Authentication on an Azure AD account.   Enable $St = New-Object -TypeName Microsoft.Online.Administration.StrongAuthenticationRequirement $St.RelyingParty = “*” $Sta = @($St) Set-MsolUser -UserPrincipalName ifarr@contoso.com -StrongAuthenticationRequirements $Sta…

2

Security Focus: Update Azure AD Admin Account Password

Got to love this cmdlet – Update-AzureADSignedInUserPassword ! I use it to update admin credentials on Azure AD instances that I only occasionally use. This avoids expiry aches and pains.   Want to take a look? First up, go get yourself a copy of the AzureAD module from PSGallery… Find-Module -Name AzureAD Install-Module -Name AzureAD -Verbose   Now, I…

1

Get-OneMillionDigitsofPi

After showing a customer the PI static method of System.Math, they asked, “how do I get more digits?”.   A quick bit of lateral-thinking, i.e. cheating, later and a with more than a nod to the hard work done by the folks at angio.net, here’s the wonderfully named Get-OneMillionDigitsOfPi function.   function Get-OneMillionDigitsOfPi { (Invoke-WebRequest -Uri “http://www.angio.net/pi/digits/pi1000000.txt”).Content…

0

One-Liner: Find a Renamed and Relocated AD Guest Account WITHOUT using the Well-Known SID

So… someone decided to rename and move the domain’s Guest account. You could find searching via the well-know SID… SID: S-1-5-21domain-501 Name: Guest Description: A user account for people who do not have individual accounts. This user account does not require a password. By default, the Guest account is disabled. Or… you could try this little trick…  …

0