Mass PST Importing using AZCopy

Ooooofff!! Been a while, man! Long time no write ??‍♂️

So, a little bit of back story – sometimes I need to import a tonne of PSTs to people O365 account for my job. I used to do this in a VERY manual way of adding their account to my Outlook and running the import. Or just giving them the PST with a guide to importing. Something needed to change!

I found a better way, I could use AZCopy to upload the files to an Azure Storage Blob and then import automatically using the built-in O365 admin tools.

First step!

Login to and head into the Information Governance -> Import section. Create a new ‘Import’ and name is as you like, not special characters though!

Select the option to upload your data, and copy the SAS URL link. The download the Azure AzCopy program. This is what we use to upload the PST files.

Second Step!

Open a command prompt or PowerShell in the same location as the AzCopy program and run the below command:

azcopy.exe copy “path to PST files” “SAS URL” –recursive

I used the recursive option as, without it, my operation wasn’t seeing the PSTs.

Leave this to run, it can take a while depending on your data. There are other parameters to this but I didn’t use them.

Third Step!

Create a PST Import mapping file – this is the step that confused me but hopefully, I can shed some light on it! Download a copy of it from here

I left the TargetRootFolder, ContentCodePage, SPFileContainer, SPManifestContainer and SPSiteURL empty. Since my data was in the following path ‘E:\Company\over_20gb’ I needed to set the FilePath to ‘over_20gb’ for all entries.

This is an example of my file:

Workload FilePath Name Mailbox IsArchive

Exchange over_20gb FALSE

Fourth Step!

Repeat step one until the upload, tick box buttons for I’m done uploading my files AND I have access to the mapping file. Use the Select mapping file and upload your file. Following that, you can Validate.

If all is well after the validation, you can either choose to filter your data or not and start the import.

The progress of this import is visible on the Importing page. Be prepared to wait as it can take a looooong time!

Enjoy! ?

Sending Custom HTML Emails via PowerShell

Hi Everyone,

I hope COVID restrictions are starting to ease for you all. Still, don’t want to let your guard down too much, ey! Better safe than sorry.

In this post, I’m showing a simple way to send HTML emails from PowerShell. This includes sending emails that contain local images instead of hosting them on a separate website. I might have done this in the past, but I want to just throw this out there again. Lets hop in!

First of all, HTML shows different on EVERY SINGLE DEVICE. Outlook is particularly bad, completely ignoring the head that might contain styling and CSS. So the only way around this is to put the styling on every single element in the HTML body.

Here is the HTML I used, we will discuss what is happening below:

<!DOCTYPE html>
    <html lang="en" xmlns="" xmlns:o="urn:schemas-microsoft-com:office:office">
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1">
        <meta name="x-apple-disable-message-reformatting">
        <!--[if mso]>
            p {
                font-family: Arial, sans-serif;
<body style="margin:0;padding:0;">
        <table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0">
                <td align="center" style="padding:0;">
                    <table role="presentation"
                            <td align="center" style="padding:40px 0 10px 0">
                                <img src="cid:logo.png" alt="" width="350" style="height:auto;display:block;" />
                            <td style="padding:10px 10px 10px 10px;">
                                <table role="presentation"
                                    <!--First chunk-->
                                        <td style="padding:0 0 20px 0">
                                                style="font-size:38px;margin:0 0 20px 0;font-family:Arial,sans-serif;text-align:center;">
                                                Information Technology
                                                style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family:Arial,sans-serif;">
                                                Dear $firstname,
                                            <h2 style="font-size:22px;margin:0 0 10px 0;font-family:Arial,sans-serif">
                                                style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family:Arial,sans-serif;">
                                                Generic text can go here
                                            <h2 style="font-size:22px;margin:0 0 10px 0;font-family:Arial,sans-serif">
                                                Your Login Information
                                                style="margin:0 0 12px 0;font-size:16px;line-height:24px;font-family:Arial,sans-serif;">
                                                More generic text
            <td style="padding:30px;background:#272a36;">
                <table role="presentation"
                        <td style="padding:0;width:50%;" align="center">
                            <p style="margin:0;font-size:18px;line-height:16px;font-family:Arial,sans-serif;color:#ffffff;">
                                For an additional support, or if you have any questions, please
                                send an email to <a href=""
  • Setting the Office product details and pixel density information
  • The logo.png is loaded using the cid: prefix which looks at the loaded images, you can see this below
  • The rest is just generic HTML with inline styling

Next we need to start creating the PowerShell email object.

#Define a valid SMTP server to send your emails through
$smtpServer = 'SERVER HERE' #e.g
#Define a new SMTP object using the server defined above
$smtpObject = New-Object Net.Mail.SmtpClient($smtpServer)

#Create a new mail message object 
$msg = New-Object Net.Mail.MailMessage
$msg.From = ''
$msg.ReplyTo = ''
$msg.subject = 'Example Email Subject'
$msg.IsBodyHtml = $True

$msg.Body = 'HTML FROM ABOVE - This can be a separate variable or right here'

#Provide a path to the photos for the email
$scriptPath = 'C:\example'

#Create a new mail attachment as an image
$logo = New-Object System.Net.Mail.Attachment -ArgumentList "$scriptPath\logo.png"
$logo.ContentDisposition.Inline = $True
$logo.ContentDisposition.DispositionType = "Inline"
$logo.ContentType.MediaType = "image/png"
$logo.ContentId = 'logo.png'

#Add the image attachment to the email, this allows the HTML to use the cid: prefix

#Try to send the email
    Write-Host 'Failed to send the email: ' -ForegroundColor Red -NoNewLine
    Write-Host $Error[0] -ForegroundColor Red

#Dispose of the image attachments and the email object to avoid memory leaks

Hopefully this shows just how easy it is to create and send HTML emails using PowerShell, including images send directly from the script instead of hosting them and suppling a web page URL.

If you have any questions etc, feel free to comment and I’ll help however I can.

Enjoy! ?

Swaks Email Scripting

Hi, in this blog post I will show you how I configured Swaks for sending emails using SMTP using my custom SMTP server.

First I ran the following command to install swaks:

sudo apt-get install swaks

With swaks installed, I could start building a test command just to
see if this would actually work. I started with the below command:

swaks --to --from --auth --auth-password=passwordforsource@email.comaccount --server -tls

This gave me an error along the lines of “Could not authenticate – connection refused” after talking to the people hosting my SMTP server, I found out that I needed to make sure that I was using port 587 and not the default port of 465.

So I made sure that my command explicitly used that port by adding it to the server parameter and managed to get an email to successfully send. You can see the code I used below:

swaks --to --from --auth --auth-password=passwordforsource@email.comaccount --server -tls


I wanted to use this in a script so that I could launch the script and an email would get sent. I also wanted to change what would get sent in the actual email since currently, it was just using the default values.

After 5 or so minutes of cobbling a script together, I came up with what you can see below:



swaks --to \ \
--auth \ \
--auth-password=password-for-source-email \
--server \
--body "$hostname - uptime is $uptime" \
--header "Subject: $hostname is still up" \
-tls \

Now I can send this email whenever I want, I even created a CRON job to send the email every hour. Enjoy!

LAPS Winform


I have created the *final* iteration of this WPF form which can be found here


I didn’t like having to remote desktop into my domain controller and couldn’t figure out if there was a LAPS tool included in RSAT tools so I decided just to make my own and to add some extra features.

I wanted the GUI to look pretty much identity to the actual LAPS GUI. You can see the difference below:

You might be able to see that I  changed the “Set” button to say “Set and Update”. This was because I wanted the form to also attempt to update the group policy settings on the computer so that it would get a new password a lot quicker than the original GUI.

There’s not much else I can say, I will leave the entire script below for you to copy and paste. You will need to add the domain controller for your environment in the $domaincontroller variable at the top of the script. I have converted this to an EXE and run whenever I need it, never skips a beat. Let me know how you get on with it. Enjoy!

Add-Type -AssemblyName

$domaincontroller = ""

[string]$icon64 = "iVBORw0KGgoAAAANSUhEUgAAAEEAAAA5CAYAAABphkbpAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAB5kSURBVGhDpXt5cFXHne7j/TN/vKr33lRsa7lXV9KV7r3S1b1akcCAQWKXQEK7hAQICSTATjI1M37UeItdFY8dO2MncVyVpTLjmedZY7ABLYCIoTLl2PFCbLzFjrFjs9gGHmDQvn7v+37nHFkEucr2NPTtc0736e7f17+1++i/YXYaHeHPlJuBCeZJu2KaZtbNOLOqdT/FH5VeZpqcdt61ujH2MMn7KeVJNpni6xNeU7cPjjMxZc003jifaRhrM9O/+pxi/RTG7H3nHtNq6V67eXpKvXxx/RTrx6ZHeU1CxodZAteCMDHICXCo6TEONMFm+uXjKZdyTUoFidJEpt1BJidV2pXz3M0aUE91PW7Td/5Nqk6kijjLbDY7CxGVHggTzvh6U0BMTrv9zozv1Hv3M+N+Qb3lEQIwLDCuA2GI1XpBaI9rmpa9Z5rQNCdo8+OvSu/aS5qABtNERbwIdqG0fPzF5/F///5n+Nt77sQ9t/8VHn/oQez5x3/Eh2//ntUczSV8etopLXtgMHmc5hCkJOKskXNnAHxxvXEKuZLsBwzOxQljY2qlnmYGdQp1wJfcZ6pWGuPkNJSyjaPxVXrZ3pvCieMv4a927sDNkSyUpAaxNBxBWTQbpdGok8NRFAbSsLSkGN+57x6cPnfWuhofJ/juWEaTsu5nj/F1M0UQw1rc60Dg0JNs4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.IO.MemoryStream][System.Convert]::FromBase64String($icon64)
$iconbmp = [System.Drawing.Bitmap][System.Drawing.Image]::FromStream($iconstream)
$iconhandle = $iconbmp.GetHicon()
$icon = [System.Drawing.Icon]::FromHandle($iconhandle)

$lapsform = New-Object    
$lapsform.Size = New-Object System.Drawing.Size(400,320)
$lapsform.Text = "                                     LAPS UI         "
$lapsform.StartPosition = "centerscreen"
$lapsform.FormBorderStyle = "fixed3d"
$lapsform.Icon = $icon

$lapsform_computername_textbox_label = New-Object System.Windows.Forms.Label
$lapsform_computername_textbox_label.Location = New-Object System.Drawing.Point(20,20)
$lapsform_computername_textbox_label.Size = New-Object System.Drawing.Size(100,15)
$lapsform_computername_textbox_label.Text = "ComputerName"

$lapsform_computername_textbox = New-Object System.Windows.Forms.TextBox
$lapsform_computername_textbox.Location = New-Object System.Drawing.Point(21,40)
$lapsform_computername_textbox.Size = New-Object System.Drawing.Size(250,15)

$lapsform_computername_textbox_keydown = {}

$lapsform_computername_textbox_keydown = [System.Windows.Forms.KeyEventHandler]{
    if ($_.keycode -eq 'Enter'){


$lapsform_search_button = New-Object System.Windows.Forms.Button
$lapsform_search_button.Location = New-Object System.Drawing.Point(290,40)
$lapsform_search_button.Size = New-Object System.Drawing.Size(60,20)
$lapsform_search_button.Text = "Search"

    if ($lapsform_computername_textbox.Text.Length -le 0){
        $lapsform_output_label.Text = "You must enter a computer name"
            #getting text from textbox
            $computernametext = $lapsform_computername_textbox.Text

            #checking if computer is in AD
            $checkad = Get-ADComputer -Identity $computernametext
            #invoking admpwdpassword command on $domaincontroller
            $invokegetadmpwd = Invoke-Command -ComputerName $domaincontroller -ScriptBlock {get-admpwdpassword -ComputerName $args[0] } -ArgumentList $computernametext | Select-Object Password, expirationtimestamp
            #getting password and password expiration date
            $lapsform_password_textbox.Text = $invokegetadmpwd | Select-Object -ExpandProperty password
            $lapsform_password_expires_textbox.Text = $invokegetadmpwd | Select-Object -ExpandProperty expirationtimestamp

            $lapsform_output_label.text = ""

            if (!$checkad){
                $lapsform_output_label.Text = "Computer not found"
            #clears password and expiry textbox
            $lapsform_password_textbox.Text = ""
            $lapsform_password_expires_textbox.Text = ""

$lapsform_password_textbox_label = New-Object System.Windows.Forms.Label
$lapsform_password_textbox_label.Location = New-Object System.Drawing.Point(20, 90)
$lapsform_password_textbox_label.Size = New-Object System.Drawing.Size(100,20)
$lapsform_password_textbox_label.Text = "Password"

$lapsform_password_textbox = New-Object System.Windows.Forms.TextBox
$lapsform_password_textbox.Location = New-Object System.Drawing.Point(21,110)
$lapsform_password_textbox.Size = New-Object System.Drawing.Size(250,15)
$lapsform_password_textbox.ReadOnly = $true
$lapsform_password_textbox.Font = New-Object System.Drawing.Font("courier",12,[System.Drawing.FontStyle]::Regular)

$lapsform_password_expires_textbox_label = New-Object System.Windows.Forms.Label
$lapsform_password_expires_textbox_label.Location = New-Object System.Drawing.Point(20,145)
$lapsform_password_expires_textbox_label.Size = New-Object System.Drawing.Size(100,20)
$lapsform_password_expires_textbox_label.Text = "Password Expires"

$lapsform_password_expires_textbox = New-Object System.Windows.Forms.TextBox
$lapsform_password_expires_textbox.Location = New-Object System.Drawing.Point(21,165)
$lapsform_password_expires_textbox.Size = New-Object System.Drawing.Size(250,15)
$lapsform_password_expires_textbox.ReadOnly = $true

$lapsform_datetime_picker_label = New-Object System.Windows.Forms.Label
$lapsform_datetime_picker_label.Location = New-Object System.Drawing.Point(20,200)
$lapsform_datetime_picker_label.Size = New-Object System.Drawing.Size(150,20)
$lapsform_datetime_picker_label.Text = "New Expiration Time"

$lapsform_datetime_picker = New-Object System.Windows.Forms.DateTimePicker
$lapsform_datetime_picker.Location = New-Object System.Drawing.Point(21,220)
$lapsform_datetime_picker.Size = New-Object System.Drawing.Size(250,15)
$lapsform_datetime_picker.Format = "custom"
$lapsform_datetime_picker.CustomFormat = "dd MMMM yyyy"

$lapsform_datetime_set_button = New-Object System.Windows.Forms.Button
$lapsform_datetime_set_button.Location = New-Object System.Drawing.Point(285,220)
$lapsform_datetime_set_button.Size = New-Object System.Drawing.Size(91,20)
$lapsform_datetime_set_button.Text = "Set and Update"


    if ($lapsform_computername_textbox.Text.Length -le 0){
        $lapsform_output_label.Text = "You must enter a computer name"
            $datetimepickervalue = $lapsform_datetime_picker.value.ToString("MM dd yyyy")
            #getting text from textbox
            $computernametext = $lapsform_computername_textbox.Text
            #checking if computer is in AD
            $checkad = Get-ADComputer -Identity $computernametext
            #invoking admpwdpassword command on $domaincontroller
            Invoke-Command -ComputerName $domaincontroller -ScriptBlock {reset-admpwdpassword -ComputerName $args[0] -wheneffective $args[1] } -ArgumentList $computernametext, $datetimepickervalue 

            #setting value of output label
            $lapsform_output_label.Text = "Password reset request was successful - GP updating - PLEASE WAIT"

            Invoke-GPUpdate -Computer $computernametext -ErrorAction SilentlyContinue

            $lapsform_output_label.Text = "Finished"
            #checking if computer is in AD
            if (!$checkad){
                $lapsform_output_label.Text = "Computer not found"
                write-host "Another issue - WinRM probably isn't allowed..."


$lapsform_output_label = New-Object System.Windows.Forms.Label
$lapsform_output_label.Location = New-Object System.Drawing.Point(1,265)
$lapsform_output_label.Size = New-Object System.Drawing.Size(385,20)
$lapsform_output_label.BackColor = "white"
$lapsform_output_label.BorderStyle = "fixedsingle"


Mailto in SharePoint String Builder

Bit of a weird, one off sort of thing. I was creating a workflow in SharePoint which would send an email. On this email would be an “Approve” and “Decline” button. The decline button was easy enough to do but the approve button turned out to be a complete pain in the back side.

First of all, I would like to tell you to not use mailto whenever you can. There are better programs out there. Trust me. If anyone knows any really good ones that they standby please feel free to leave a comment.

The mailto syntax is basically this:


This looks simple enough but once you want to start doing some more complicated features/formatting that would otherwise be quite simple in HTML, become near impossible here. Especially with it being in a SharePoint string builder box.

What I wanted was for there to be three lines of text, two in which got information from the SharePoint form to fill in the information and one for adding text. By the way if you didn’t know, to add a new line you can use “%0d0d“.

That’s: percent sign – zero – delta – zero – delta

This is the final code that I ended up with:

mailto:RECIPIENT@EMAIL.COM?cc=[%Current Item:Created By%]&subject=Approval Authorisation for [%Current Item:Created By%]&body=The remote access request for [%Current Item:Created By%] has been approved by [%Current item:Manager's Name%]%0d%0dThe reason for approval is - [%Current Item:Reason for approval%]%0d%0dPlease specify any limitations below:

Here is a picture just in case you want to see it and below that what the actual email looks like:

String Builder


I would like to add that you will have to change the “Add or Change Lookup” so that it finds the “Display Name”, otherwise the users will show as the default SharePoint format which isn’t as good looking. You can see this below:

Display Name

Hope you enjoyed and found this useful. I may to an entire blog trying to outline the possibilities of using the SharePoint string builder and “Define E-Mail Message” features. Suppose you’ll have to wait and see.

More Auto-Loading, Custom PowerShell Scripts

In this update, you’ll see how I added two or three new scripts to the environment and also changed how most of the scripts work.

One new script that I add was a script that would take CSV data and add the users to a group in Active Directory. You can see this below:

function Get-CSVAddToGroup{
 This function allows you to add usernames from a CSV to a specified Active Directory group.
 It needs confirmation for each addition to a group.

 Get-CheckCSVAddToGroup -Groupname "all rossendale staff" -path c:\testing\test.csv



 $csvformembership = Import-Csv -Path $path

 foreach ($b in $csvformembership){
  $name = $b.user
  Add-ADGroupMember -Identity "$groupname" -Members $name -Confirm

Another script I added was my script for sending messages to remote computers on the network. You can see this below:

function Send-Message{

 function send-messagewithname{
  $name = Read-Host "Enter a name"
  $msg = Read-Host "enter a message"
  $adcompstocheck = Get-ADComputer -LDAPFilter "(name=$name)" -Properties name

  if ($adcompstocheck -eq $null){
   Write-Host "$name doesn't exist!"
   Invoke-WmiMethod -Path win32_process -Name create -ArgumentList "msg * $msg" -ComputerName "$name"

 function send-messagewithip{
  $ip = Read-Host "enter an IP"
  $msg = Read-Host "enter a message"
  $adcompstocheckip = Get-ADComputer -Filter * -Properties ipv4address, name | select ipv4address
  if ($adcompstocheckip -eq $null){
   write-host "$ip doesn't exist"
   Invoke-WmiMethod -Path win32_process -Name create -ArgumentList "msg * $msg" -ComputerName "$ip"

 do {$nameorip = Read-Host "Do you want to use IP or Name (I or N)?"} while (("i","n") -notcontains $nameorip)
 if ($nameorip -eq "n"){
 }else {

Finally, my last script that was added to my custom PowerShell environment allowed me to list all the computers on the network with a specific operating system. For example “2012” or “Professional”. The code for this is below:

function list-OSVersonComputers{
 This function allows you to list all of the computers with the requested OS version.

 List-OSVersionComputers -OSVersion 2012

 List-OSVersionComputers -OSVersion standard

 $OSVersion2 = '*' + ($OSVersion) + '*'

 Get-ADComputer -Filter {OperatingSystem -like $OSVersion2} -Property * | Format-Table name,operatingsystem,lastlogondate -Wrap -AutoSize

I also added help menus to most of my scripts to make them more professional.

Customized Email Signatures In HTML

Back off holiday, want to do something simple. So email signature it is.

I made mine in the Mimecast administrator center as a way to become more familiar with HTML so that I could create an actual signature for some users.

Before we look at the code – I will put an image below of what the signature would actually look like. Also, I own NONE of the images/sites shown here. (Sorry, just didn’t want legal people sniffing around).


Now that you have seen the signature, you can see that is it in no way a real world example of something that should be used. But I also couldn’t use the actual one for…reasons. I just wanted to show you every feature I used in the real one.

Below is the actual code I used:

  <body><mc type="body">
  <p style="font-family:calibri:">This is a <b>test</b> email signature</p>

  <img src="" alt="TEST LEFT" style="float:left;width:50px;height:20px;" />
  <p style="font-family:courier;">This is the second line of the test email signature</p>
  <p style="font-family:verdana;font-size:80%;">This is the last line of the test email signature</p>

  <img src="" alt="TEST IMAGE" style="width:200px;height:70px;" />

  Click <a href="" target="_blank"><i>here</i></a> to open a link


You may notice that I have linked Krebs blog – Enjoy!

Adding Signatures In Mimecast

Bit different from, the now usual, Powershell guides. Thought I’d do something different. This guide will show you how to add a custom signature to a user, multiple users’ or even globally.

Lets start off. You’ll want to log into your Mimecast administrative console, go to Service-Gateway-Policies. In here you should see “Stationary”. We want to create a new definition, so click on the “Definition” button on the “Stationary” listing.

Here you can click the “New Item” button. For the Description, obviously, enter a brief description of the new definition. The “Unique Identification Text” is used to scan an email that the definition is applied to to determine if the signature has already been added, so you want to add something that is in the signature and something that is unique to this signature. For the short code, enter a unique name. Below is an example of mine:


Now we want to edit the HTML so that there actually is a signature to put onto the emails. Click on the “Edit HTML” button and enter your signature. This is the code I added to mine:

    <mc type="body">

    <font size="2" color="gray">
    This is a test email signature for marketing

    <img src="IMAGE LINK" alt="ALTERNATIVE IMAGE NAME" style="width:214px;height:24px:" />


So in my signature I have the message “This is a test email signature for marketing” and also a company logo.

Now we have that, we need to add it to an actual policy, otherwise it simply won’t be used by anything. Navigate back after saving your definition to the “Policies” page and click on the “Stationary” row. You now want to click “New Policy” which should open up a new policy creation window.

For the “Policy Narrative” enter a name for the policy, for the “Select Stationary”, select “lookup”, find your newly created definition and click “Select”. Since I created mine as a test and my Mimecast access is on my business email address, I configured an individual send and to email address for the policy to apply to. On this page you can also select when the policy will be active or even a range of source IP addresses.

Below are the values that I entered. The emails are removed for obvious reasons:


Finally, below is an example of an email with the newly added signature:


You should now have a custom signature that applies to every user defined in the policy instead of individual users.