• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Tachytelic.net

  • Get in Touch
  • About Me

How To

Specify Display Name when sending Email with PowerShell

October 4, 2019 by Paulie 5 Comments

Sending email with PowerShell is easy with Send-MailMessage. Here is a basic example:

$server = "smtp.sendgrid.net"
$Username ="test"
$Password = ConvertTo-SecureString "Password" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $Username, $Password
$from = "[email protected]"
$to = "[email protected]"
$subject = "Test Message"
$mailbody = @"
Hi Paulie,

This is a test message.

See you soon
"@

Send-MailMessage -smtpServer $server -Credential $credential -Usessl -Port 587 -from $from -to $to -subject $subject -Body $mailbody 

The PowerShell example above sends the email via Sendgrid and works perfectly. But the problem is that the “from” address appears exactly as “[email protected]” and there is no obvious way to specify the display name.

Specifying the Display Name with Powershell

To specify the display name when sending email via Powershell. You can build the from address by creating a System.Net.Mail.MailAddress Like this:

$from = new-object System.Net.Mail.MailAddress("[email protected]", "Paulie")

During my testing whenever I sent a message without a display name, the received message went straight to my “clutter” folder in Outlook. But with the display name included in came to my inbox.

Filed Under: How To Tagged With: Powershell

How to enable SMB1 on Windows 10

September 25, 2019 by Paulie 15 Comments

If you try to access an SMB 1 share from Windows 10 you may receive the following error message:

You can’t connect to the file share because it’s not secure. This share requires the obsolete SMB1 protocol, which is unsafe and could expose your system to attack. Your system requires SMB2 or higher.

Enable SMB1 on Windows 10

  1. Press Windows Key + R to bring up the run dialog and type:
    optionalfeatures
    Image showing the Windows 10 run dialog box
  2. Expand “SMB 1.0/CIFS File Sharing Support” and then check the box next to “SMB 1.0/CIFS Client“
    Image showing the installation of SMB 1 support in Windows 10
  3. Click OK
  4. The installation will now proceed and you should be able to access shares using the SMB 1 Protocol again.

Enable SMB1 on Windows 10 with PowerShell

If you would prefer to do a command line installation, use the following command from an elevated PowerShell Prompt:

Enable-WindowsOptionalFeature -Online -FeatureName "SMB1Protocol-Client" -All

For more information see:
https://support.microsoft.com/en-gb/help/4034314/smbv1-is-not-installed-by-default-in-windows

Filed Under: How To Tagged With: Windows 10

How to Upgrade Dell XPS 8900 SSD

September 21, 2019 by Paulie 26 Comments

There is a some inaccurate information on how to upgrade the Dell XPS 8900 SSD on the web, so I thought I would quickly write up my experience.

I’ve had my Dell XPS 8900 for a few years now and the primary storage is out of space. But other than that it is still a decent machine.

The XPS 8900 has an M.2 / SATA slot. So it is not a NVMe capable. More information can be found in the XPS 8900 Service Manual here.

My machine came with a Lite-On 256Gb drive and I have replaced it with a 1TB Samsung 860 EVO M.2 but there are other sizes which might suit you better.

Title
Samsung SSD 860 EVO 500GB M.2 SATA Internal SSD (MZ-N6E500BW)
Samsung SSD 860 EVO 1TB M.2 SATA Internal SSD (MZ-N6E1T0BW)
Samsung SSD 860 EVO 2TB M.2 SATA Internal SSD (MZ-N6E2T0BW)
Price
$132.05
$138.99
Price not available
Preview
Samsung SSD 860 EVO 500GB M.2 SATA Internal SSD (MZ-N6E500BW)
Samsung SSD 860 EVO 1TB M.2 SATA Internal SSD (MZ-N6E1T0BW)
Samsung SSD 860 EVO 2TB M.2 SATA Internal SSD (MZ-N6E2T0BW)
Buy
Buy on Amazon
Buy on Amazon
Buy on Amazon
Rating
-
-
-
Title
Samsung SSD 860 EVO 500GB M.2 SATA Internal SSD (MZ-N6E500BW)
Price
$132.05
Preview
Samsung SSD 860 EVO 500GB M.2 SATA Internal SSD (MZ-N6E500BW)
Buy
Buy on Amazon
Rating
-
Title
Samsung SSD 860 EVO 1TB M.2 SATA Internal SSD (MZ-N6E1T0BW)
Price
$138.99
Preview
Samsung SSD 860 EVO 1TB M.2 SATA Internal SSD (MZ-N6E1T0BW)
Buy
Buy on Amazon
Rating
-
Title
Samsung SSD 860 EVO 2TB M.2 SATA Internal SSD (MZ-N6E2T0BW)
Price
Price not available
Preview
Samsung SSD 860 EVO 2TB M.2 SATA Internal SSD (MZ-N6E2T0BW)
Buy
Buy on Amazon
Rating
-

I wanted to clone my existing SSD to the new drive and Samsung provide easy to use data migration software with their SSDs.

The problem is because the existing drive is in the internal m2 slot there is no way to clone the drive without additional hardware. So I also bought this external Transcend M.2 Drive Enclosure:

Transcend TS-CM80S M.2 2280/2260 to USB3.1 Upgrade Kit, Silver
Transcend TS-CM80S M.2 2280/2260 to USB3.1 Upgrade Kit, Silver
  • M.2 SSD enclosure kit
  • Lightweight yet durable aluminum construction
  • CM80 enclosure is for Type 2242, 2260, and 2280 m.2 SSD
  • All-inclusive package
  • Usb Type-A and Type-C supported
$29.99
Buy on Amazon

I put the new Samsung SSD in the external enclosure and then connected it to the USB 3 port on the front of the Dell XPS 8900 and ran the transfer, it took about 40 minutes to finish.

Once it was complete I installed the new drive in the machine:

Image of Samsung EVO 860 Installed in Dell XPS 8900
Samsung EVO 860 installed inside Dell XPS 8900

I put the original drive into the external enclosure to make use of it again.

Overall this is a quick and easy upgrade to perform., the most difficult part is sliding the graphics card out of the machine. Any m.2 sata SSD should work and there are cheaper options than the Samsung available.

Can you install an NVMe drive in the Dell XPS 8900?

The procedure above is quick and simple to do, but the performance of the SSD will be limited by the SATA interface. If you want the best performance from your XPS 8900 use an NVMe drive connected to a spare PCIe slot.

Although the XPS 8900 does not have an NVMe slot, it is capable of booting from one. I used this cheap NVME to PCIe 3.0 x4 Adapter from Amazon with a Samsung 970 PRO 512GB and got some impressive results:

Here is the benchmark results of the Samsung 860 on the internal M2 slot:

As you can see, the NVMe drive provides a huge performance increase over the SATA based M2 slot on the motherboard. The other advantage of this approach is that you do not need to remove the graphics card in order to install it, here is the card:

It also comes with a heatsink which I put on before putting it into the machine, below the graphics card:

This is a cheap and easy way to give a performance boost to an older machine, let me know your results if you try it.

Filed Under: How To

VBA – Add Items to Array

September 4, 2019 by Paulie 8 Comments

VBA does not allow you to append items to an array. The standard method to work around this is to re-dimension to array to the required size and then add the required items.

Take the following code as an example:

Dim VbaArrayNames() As String
ReDim Preserve VbaArrayNames(0)
VbaArrayNames(0) = "Peter"
ReDim Preserve VbaArrayNames(1)
VbaArrayNames(1) = "Paul"
ReDim Preserve VbaArrayNames(2)
VbaArrayNames(2) = "Andy"

There are a number of problems with this method:

  • Performance – The array is copied into a new array each time it is re-dimensioned.
  • Readability – Lots of additional code we can do without.
  • Sorting – There is no easy way to sort the data.
  • Removal – No Simple way to remove an element from the array.

There is another method which is much easier, faster and has more functionality, and that is to use the ArrayList class from .net framework:

Set DotNetArray = CreateObject("System.Collections.ArrayList")
DotNetArray.Add "Peter"
DotNetArray.Add "Paul"
DotNetArray.Add "Andy"
DotNetArray.Sort
Dim Name As Variant
For Each Name In DotNetArray
    Debug.Print Name
Next
Image showing how to add items to a VBA array.
It’s easy to add or remove items and sorting is a one liner.

As you can see the array can easily be sorted without having to resort to bubble sort methods and the code is much cleaner.

If you are working with large arrays there will certainly be a performance boost, and even if you aren’t, the code will be much cleaner.

Some of the other useful methods:

Remove an element from the array

DotNetArray.Remove "Andy"

Check if the array contains a particular value using the contains method

This will return true or false depending on the result.

If DotNetArray.contains("Paul") Then
    Debug.Print "Paul is in the array"
Else
    Debug.Print "Paul is not in the array"
End If

Reverse the Array with the reverse method

Just like sorting, reversing the array can be done in an instant:

DotNetArray.Reverse

Adding items to a VBA array is just much easier when using the arraylist class. You can also do exactly the same in VBScript and Powershell, which I have covered in the linked posts.

Filed Under: How To Tagged With: VBA

Multiline comments in PowerShell

August 29, 2019 by Paulie Leave a Comment

Adding a comment block is easy in Powershell, you simply start the comment with <# and end it with #>

Image showing a multi line comment in Powershell

Windows PowerShell ISE can comment multiples lines. Simply hold down Alt-Shift-Up/Down and select the block of code that you want to comment and then press # or backspace to remove the comment, like so:

Animated GIF showing how to comment multiple lines of code with Windows PowerShell ISE

Filed Under: How To Tagged With: Powershell

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Go to page 5
  • Interim pages omitted …
  • Go to page 13
  • Go to Next Page »

Primary Sidebar

Link to my LinkedIn Profile
Buy me a coffee

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 259 other subscribers.

Go to mobile version