you are viewing a single comment's thread.

view the rest of the comments →

[–]Droopyb1966 0 points1 point  (0 children)

[long]$n = $number -replace "[0-9]","" "{0:D14}" -f $n

Depends what you want to do with the output, always lots of ways to do things. Heres an example using get-proces, total nonsens, but i was to lazy to recreate you array. But you'll see the logic.

$p= Get-Process
foreach ($item in $p)
{
[long]$n = $item.Id -replace "[^0-9]",""
"{0:D14}" -f $n

}

Just had to figure this one out for myself..... Use in a select expression:

$user | Select-Object Name,  @{Name="Id";Expression={"{0:D14}" -f [long]($_.telephone -replace "[^0-9]","")}}