Using the Convert Module in PowerShell

When you have Objects in a format that you can’t read, or when you want to convert Objects to another format, or to switch from Celsius to Fahrenheit, you can use the Cmdlets from the Convert module from Andrew Pearce 🙂 In this small blog post, I will show you how you can use this great module!

What does the Convert module do?

“Convert is a PowerShell Module that simplifies object conversions by exposing common requirements as standard PowerShell Functions. For example, this module includes functions for converting to and from Base64 encoded strings, MemoryStream objects, or Clixml output.”

Source: https://github.com/austoonz/Convert

How to install?

It’s available from the PSGallery and can be installed by running:

Install-Module Convert -AllowClobber

Aliases/Functions

Below is an overview of the Cmdlets/Aliases/Functions and what you can do with them. I will show you the basic usage, but check out Andrew‘s excellent documentation site for more detailed information: https://convert.readthedocs.io/en/latest/.

ConvertFrom-Base64

This allows you to convert Base64-encoded strings to regular strings, for example:

PS C:\Users\HarmVeenstra> 'UG93ZXJzaGVsbCBpcyBmdW4h' | ConvertFrom-Base64 -ToString
Powershell is fun!

ConvertFrom-Base64ToByteArray

You can convert a Base64-encoded string to a Byte Array, for example:

PS C:\Users\HarmVeenstra> ConvertFrom-Base64ToByteArray -String 'UG93ZXJzaGVsbCBpcyBmdW4h'
80
111
119
101
114
115
104
101
108
108
32
105
115
32
102
117
110
33

ConvertFrom-Base64ToMemoryStream

You can use this to convert from a Base64-encoded string to a Memory Stream (a class that provides a stream implementation for in-memory data, unlike traditional file-based streams, it allows developers to read from and write to memory as if it were a file), for example:

PS C:\Users\HarmVeenstra> ConvertFrom-Base64ToMemoryStream -String 'UG93ZXJzaGVsbCBpcyBmdW4h'

CanRead      : True
CanSeek      : True
CanWrite     : True
Capacity     : 18
Length       : 18
Position     : 0
CanTimeout   : False
ReadTimeout  :
WriteTimeout :

ConvertFrom-Base64ToString

Unlike ConvertFrom-Base64, which has a few more options, this Cmdlet takes a Base64-encoded string and converts it to a regular string. For example:

PS C:\Users\HarmVeenstra> 'UG93ZXJzaGVsbCBpcyBmdW4h' | ConvertFrom-Base64ToString
Powershell is fun!

ConvertFrom-ByteArrayToBase64

This is the other way around from ConvertFrom-Base64ToByteArray, for example:

PS C:\Users\HarmVeenstra> ConvertFrom-Base64StringToByteArray -String 'UG93ZXJzaGVsbCBpcyBmdW4h' | ConvertFrom-ByteArrayToBase64
UA==
bw==
dw==
ZQ==
cg==
cw==
aA==
ZQ==
bA==
bA==
IA==
aQ==
cw==
IA==
Zg==
dQ==
bg==
IQ==

ConvertFrom-ByteArrayToMemoryStream

And you can also convert a Byte Array to a Memory Stream, for example:

PS C:\Users\HarmVeenstra> $ByteArray=ConvertFrom-Base64ToByteArray -String 'UG93ZXJzaGVsbCBpcyBmdW4h'
PS C:\Users\HarmVeenstra> ConvertFrom-ByteArrayToMemoryStream -ByteArray $ByteArray

CanRead      : True
CanSeek      : True
CanWrite     : True
Capacity     : 18
Length       : 18
Position     : 0
CanTimeout   : False
ReadTimeout  :
WriteTimeout :

ConvertFrom-Clixml

To convert a Clixml file, you can use this cmdlet like this, for example:

PS C:\Users\HarmVeenstra> $xml = @"
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
<S>PowerShellIsFun</S>
</Objs>
"@
PS C:\Users\HarmVeenstra> convertFrom-Clixml -String $xml
PowerShellIsFun

ConvertFrom-CompressedByteArrayToString

There are also Compressed Byte Arrays, which can be converted to a String, for example:

PS C:\Users\HarmVeenstra> ConvertFrom-StringToCompressedByteArray -String 'PowerShell is fun!'
31
139
8
0
0
0
0
0
0
10
11
200
47
79
45
10
206
72
205
201
81
200
44
86
72
43
205
83
4
0
103
194
43
132
18
0
0
0
PS C:\Users\HarmVeenstra> ConvertFrom-StringToCompressedByteArray -String 'PowerShell is fun!' | ConvertFrom-CompressedByteArrayToString
PowerShell is fun!

ConvertFrom-EscapedUrl

Sometimes you have URLs containing %, which you want to convert to a standard URL. Using ConvertFrom-EscapedUrl, you can, for example:

PS C:\Users\HarmVeenstra> ConvertTo-EscapedUrl -Url 'https://powershellisfun.com'
https%3A%2F%2Fpowershellisfun.com
PS C:\Users\HarmVeenstra> ConvertFrom-EscapedUrl -Url 'https%3A%2F%2Fpowershellisfun.com'
https://powershellisfun.com

ConvertFrom-MemoryStream

To convert a Memory Stream to a base64-encoded string, you can use ConvertFrom-MemoryStream. For Example:

PS C:\Users\HarmVeenstra> 'PowerShell is fun!' | ConvertTo-MemoryStream | ConvertFrom-MemoryStream -ToString
PowerShell is fun!

ConvertFrom-MemoryStreamToBase64

It is the same as above, but converts it straight to Base64. For example:

PS C:\Users\HarmVeenstra> 'PowerShell is fun!' | ConvertTo-MemoryStream | ConvertFrom-MemoryStreamToBase64
UG93ZXJTaGVsbCBpcyBmdW4h

ConvertFrom-MemoryStreamToByteArray

This Cmdlet will convert a Memory Stream to a Byte Array, for example:

PS C:\Users\HarmVeenstra> 'PowerShell is fun!' | ConvertTo-MemoryStream | ConvertFrom-MemoryStreamToByteArray
80
111
119
101
114
83
104
101
108
108
32
105
115
32
102
117
110
33

ConvertFrom-MemoryStreamToString

To convert a Memory Stream to a readable String, you can use ConvertFrom-MemoryStreamToString. For example:

PS C:\Users\HarmVeenstra> 'PowerShell is fun!' | ConvertTo-MemoryStream | ConvertFrom-MemoryStreamToString
PowerShell is fun!

ConvertFrom-MemoryStreamToSecureString

This Cmdlet will convert a Memory Stream to a Secure String, which you could use for a Credential. For example:

PS C:\Users\HarmVeenstra> 'PowerShell is fun!' | ConvertTo-MemoryStream | ConvertFrom-MemoryStreamToSecureString
System.Security.SecureString

ConvertFrom-StringToBase64

To convert a string to Base64 encoding, you can use this Cmdlet. For example:

PS C:\Users\HarmVeenstra> 'PowerShell is fun!' | ConvertTo-Base64
UG93ZXJTaGVsbCBpcyBmdW4h

ConvertFrom-StringToByteArray

To convert a string to a Byte Array, you can use this Cmdlet. For example:

PS C:\Users\HarmVeenstra> 'PowerShell is fun!' | ConvertFrom-StringToByteArray
80
111
119
101
114
83
104
101
108
108
32
105
115
32
102
117
110
33

ConvertFrom-StringToCompressedByteArray

You can use this to convert a string to a Compressed Byte Array, for example:

PS C:\Users\HarmVeenstra> 'PowerShell is fun!' | ConvertFrom-StringToCompressedByteArray
31
139
8
0
0
0
0
0
0
10
11
200
47
79
45
10
206
72
205
201
81
200
44
86
72
43
205
83
4
0
103
194
43
132
18
0
0
0

ConvertFrom-StringToMemoryStream

To convert a string to a Memory Stream, you can use this Cmdlet. For example:

PS C:\Users\HarmVeenstra> 'PowerShell is fun!' | ConvertFrom-StringToMemoryStream

CanRead      : True
CanSeek      : True
CanWrite     : True
Capacity     : 256
Length       : 18
Position     : 18
CanTimeout   : False
ReadTimeout  :
WriteTimeout :

ConvertFrom-UnixTime

I used to use websites for that, but this Cmdlet is easier 🙂 For example: (And sorry for the Dutch output 😉 )

PS C:\Users\HarmVeenstra> (Get-date) | ConvertTo-UnixTime
1747961646
PS C:\Users\HarmVeenstra> (Get-date) | ConvertTo-UnixTime | ConvertFrom-UnixTime

vrijdag 23 mei 2025 20:31:48

ConvertTo-Base64

Works the same as ConvertFrom-StringToBase64; it will convert the input to Base64 encoding. For example:

PS C:\Users\HarmVeenstra> 'PowerShell is fun!' | Convertto-Base64
UG93ZXJTaGVsbCBpcyBmdW4h

ConvertTo-Celsius

This Cmdlet will allow you to convert to Celsius from Fahrenheit, for example:

PS C:\Users\HarmVeenstra> ConvertTo-Celsius -Fahrenheit 90
32,22

ConvertTo-Clixml

This Cmdlet converts an object to CliXML, for example:

PS C:\Users\HarmVeenstra> $string='PowerShell is fun!'
PS C:\Users\HarmVeenstra> ConvertTo-Clixml -InputObject $string
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
  <S>PowerShell is fun!</S>
</Objs>

ConvertTo-EscapedUrl

This works the other way around, creating an escaped URL from a standard URL. For example:

PS C:\Users\HarmVeenstra> ConvertTo-EscapedUrl -Url 'https://powershellisfun.com'
https%3A%2F%2Fpowershellisfun.com

ConvertTo-Fahrenheit

Using this Cmdlet, you can convert from Fahrenheit to Celsius. For example:

PS C:\Users\HarmVeenstra> ConvertTo-Fahrenheit -Celsius 31
87,8

ConvertTo-MemoryStream

This Cmdlet will convert an Object to a Memory Stream, for example:

PS C:\Users\HarmVeenstra> ConvertTo-MemoryStream -String $string


CanRead      : True
CanSeek      : True
CanWrite     : True
Capacity     : 256
Length       : 18
Position     : 18
CanTimeout   : False
ReadTimeout  :
WriteTimeout :

ConvertTo-String

This Cmdlet will convert a Base64-encoded string to a string, for example:

PS C:\Users\HarmVeenstra> 'UG93ZXJTaGVsbCBpcyBmdW4h' | ConvertTo-String
PowerShell is fun!

ConvertTo-TitleCase

This Cmdlet will convert a String to Title case. For example:

PS C:\Users\HarmVeenstra> 'powerShell is fun!' | ConvertTo-TitleCase
Powershell Is Fun!

ConvertTo-UnixTime

This Cmdlet will convert time to Unix Time. For example:

PS C:\Users\HarmVeenstra> Get-Date | ConvertTo-UnixTime
1747961577

Get-Hash

This Cmdlet retrieves a string’s hash and supports the MD5, SHA1, SHA256, SHA384, and SHA512 algorithms. For example:

PS C:\Users\HarmVeenstra> Get-Hash -String 'PowerShell is fun' -Algorithm SHA512
DC5894F6BC96D4303812A807A5FC196508F75EE5D1F8AAE0F72467564BDEB920DC65C64938AD65F1465F5B8D3D61970EBA542CD9F72A1F9860EB153462EB1DF6

Get-UnixTime

To display the current time in Unix Time, you can use the Get-UnixTime Cmdlet without conversion. For example:

PS C:\Users\HarmVeenstra> Get-UnixTime
1747954462

Wrapping up

And that were all the options that you get from the Convert module, great stuff and so much easier than using websites to convert back and forth 🙂 Have a lovely weekend!

10 thoughts on “Using the Convert Module in PowerShell

  1. As directed, I entered ‘Install-Module Convert’, replied ‘Y’, and received this message (in red):

    Untrusted repository
    You are installing the modules from an untrusted repository. If you trust this repository, change its
    InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
    ‘PSGallery’?
    [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is “N”): y
    PackageManagement\Install-Package : The following commands are already available on this system:’Get-Hash’. This
    module ‘Convert’ may override the existing commands. If you still want to install this module ‘Convert’, use
    -AllowClobber parameter.
    At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
    + … $null = PackageManagement\Install-Package @PSBoundParameters
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (Microsoft.Power….InstallPackage:InstallPackage) [Install-Package],
    Exception
    + FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.Pack
    ageManagement.Cmdlets.InstallPackage

    My question is, should I use the ‘-AllowClobber’ parameter?
    Thanks,
    Dan

      1. How do I find the module it is installed in? When I issue this command:
        PS C:\Windows\system32> ‘DRB’ | ConvertFrom-StringToByteArray
        I receive this error:
        ConvertFrom-StringToByteArray : The term ‘ConvertFrom-StringToByteArray’ is not recognized as the name of a cmdlet,
        function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
        path is correct and try again.
        At line:1 char:9
        + ‘DRB’ | ConvertFrom-StringToByteArray
        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo : ObjectNotFound: (ConvertFrom-StringToByteArray:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

        So my question is, what additional path must I now supply so the CONVERT command can be found?
        Thanks,
        Dan

  2. In your first comment, the error stated “The following commands are already available on this system:’Get-Hash’. ” If you run Get-Command Get-Hash, it should tell you the modules that the Cmdlet is a part of.

    1. These are my results when I run ‘Get-Command Get-Hash’:

      PS C:\Windows\system32> Get-Command Get-Hash
      Get-Command : The term ‘Get-Hash’ is not recognized as the name of a cmdlet, function, script file, or operable
      program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
      At line:1 char:1
      + Get-Command Get-Hash
      + ~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : ObjectNotFound: (Get-Hash:String) [Get-Command], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand

      PS C:\Windows\system32>

  3. That’s strange, it should report where it was listed. But no worries, you can use Install-Module Convert -AllowClobber (updated that chapter in the blog post, too) and it should just work after that.

    1. Thanks, Harm!
      It’s now working after installing with the ‘-AllowClobber’ parameter.
      Dan

Leave a Reply to Harm VeenstraCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.