Select as many ips as possible inside 255 characters string

Imagine you have a lot of ips in array, but you want to divide them per 255 characters slices.  We join all them using a comma, and them replace comma by a semicolon

$ip4=1..30 | ForEach-Object { “192.168.1.$_” }
$ip4 -join ‘,’,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

$ip4 -join ‘,’ -replace ‘(\G.{216,255}),’,’$1;’,,,,,,,,,,,,,,,,,,,;,,,,,,,,,
$ip4 -join ‘,’ -replace ‘(\G.{216,255}),’,’$1;’ -split ‘;’ |%{‘Next result’;$_}Next result,,,,,,,,,,,,,,,,,,,
Next result,,,,,,,,,

We are aiming for the commas

We will replace a comma with our first group from the match and put a semicolon. Then we will be splitting strings on semicolons  since we know that at position of the semicolon was the position that could hold the maximum amount of ips in 255 char string area.

And let’s say we are interested only first two batches in case we got more than 30 ips
$ip4 -join ‘,’ -replace ‘(\G.{216,255}),’,’$1;’ -split ‘;’,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

$first,$second,$null = $ip4 -join ‘,’ -replace ‘(\G.{216,255}),’,’$1;’ -split ‘;’

Puts first batch to $first, second batch to $second and the rest goes to null.
This will work also with ipv6, the replace part of regex is greedy, so in case you will be working with ip6 and later with ip4, it will still find the maximum amount of ips. that’s why it has 216-255 instead of 240-255


PSTypenames for a string object

PS C:\> $myobj = ‘2222’
PS C:\> $myobj.pstypenames
PS C:\> $myobj.pstypenames.add(‘Greg’)
PS C:\> $myobj.pstypenames
PS C:\> [psobject]$myobj2=’2222′
PS C:\> $myobj2.pstypenames.add(‘Greg’)
PS C:\> $myobj2.pstypenames


You have to cast them to PSO first, as it was explained to me on #powershell-help that the string PSO do not propagate members, hence you have to make it manually

Download EJBCA certificate with powershell

i came up with this today

add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
    public bool CheckValidationResult(
        ServicePoint srvPoint, X509Certificate certificate,
        WebRequest request, int certificateProblem) {
        return true;
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

you can look up the thumbprint to compare which one it is
get-childitem Cert:\CurrentUser\My

$superadmin = get-childitem Cert:\CurrentUser\My\YOUR_SUPERADMIN_CERT_HASH
invoke-webrequest -Uri "https://infralab.local:32768/ejbca/publicweb/webdist/certdist?cmd=lastcert&installtobrowser=&" -method "Get" -Certificate $superadmin

what's left is to generate the cert order via csr. this just just downloading the already made cert.

vSphere Lookup Service MOB


Using this link:


You can access the list() method, you have to fill out the filterCriteria

Leave it ‘blank’:


and click the Invoke Method.

From the vCenter appliance itself you can  use the list() method using the

/usr/lib/vmidentity/tools/scripts/ list –url https://localhost/lookupservice/sdk –no-check-cert | grep -v ‘SSL’

Mind that it will hide the SSL part to make screen content  more readable.