Working with ArrayList table

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 8 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
waynecierkowski
Posts: 28
Last visit: Mon Jul 10, 2023 10:51 am

Working with ArrayList table

Post by waynecierkowski »

I'm fighting with this one. I have created a Arraylist table of servers from our Active Directory. Now I have a listing of all of our Virtual machines from our VMware environment. I want to replace the short name entry in the Active Directory Arraylist with the Fully Qualified Name from VMware.

The active directory arraylist table is called $MasterServerList.
The VMware entries are in two variables, $VMServerName and $VMServerNameFQN

Now doing this in plain old powershell cmd window I issue the following command,
$MasterServerList -replace $VMServerName, $VMServerNameFQN

When that command is issued it shows me a listing of the array table with the change, so far so good..

But when I just enter the array name, $MasterServerList the change is no longer present.

First question why is this happening?
How can I use the -replace command without showing me a table listing every time I replace an entry?

At the end of my program I want to dump the arraylist table out to a file.

TIA for your help...
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Working with ArrayList table

Post by jvierra »

Simple. Just save the results.

$MasterServerList = $MasterServerList -replace $VMServerName, $VMServerNameFQN
This topic is 8 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked