Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

powershell, replace an Array object with nothing

$
0
0

I need to get rid of an object ($deletehostname) in an array and have the following code:

if ($BackConnectionHostnamesExists) { $zero="" $ExistingHostnames = ($BackConnectionHostnamesExists.BackConnectionHostnames) $ExistingHostnames = $ExistingHostnames.replace($deletehostname, $zero) Set-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa\MSV1_0 -Name "BackConnectionHostnames" -value $ExistingHostnames }

$deletehostname is successfully removed, but it is replaced by an open line.

so if $deletehostname = test3, my result is:

test1

test2



test4

test5

I would love to get rid of that empty space! So is it possible to replace by nothing?

br

Bjorn



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>