How can i change the input?
-
Wednesday, May 02, 2012 6:55 PM
Hi,
I need help to change the input value. Like below is the example.
My CSV file contains below value
COMPUTER1
COMPUTER2
COMPUTER3
COMPUTER4
and also some other detailes also in the CSV file. When i get input of each Computer Name i need to change the name with another name. like if the Computer name is COMPUTER1 then the name should be changed to WINDOWS1 and if computer name COMPUTER2 then it should chnaged to WINDOWS2 and so on. And with this input i have to process ramaining thing and i will take care of that on. Thanks.
All Replies
-
Wednesday, May 02, 2012 7:08 PMModerator
Hi,
What scripting language are you using, and what have you tried so far?
Bill
-
Wednesday, May 02, 2012 7:13 PMI need this command in powershell. My requirement is a big task. I have completed almost my script. i need this help to complete my script. Thanks.
-
Wednesday, May 02, 2012 7:20 PMModerator
Hi,
Working with CSV files in PowerShell is pretty straightforward. You can use Import-Csv, which returns objects with property name = column name. You can also use PowerShell's -replace operator to replace strings. PowerShell's help system has information about both of these topics.
Bill
-
Wednesday, May 02, 2012 7:26 PMWhat is the name of the column heading which contains the names you want to change?
Grant Ward, a.k.a. Bigteddy
-
Wednesday, May 02, 2012 7:38 PM
$oldnames = Import-Csv compnames.csv foreach ($name in $oldnames) {$name."Computer Name" = ($name."Computer Name").replace('COMPUTER','WINDOWS')} $oldnames | Export-Csv compnames2.csv #debug: Import-Csv compnames2.csvGrant Ward, a.k.a. Bigteddy
-
Wednesday, May 02, 2012 8:33 PMHey, in the CSV file only Computer Name is there, so once it's processed we need match computer name with windows name then replaced those computer name with appropriate windows name. Can you please help to fix this issue by powershell command? Thanks
-
Wednesday, May 02, 2012 8:54 PMModerator
Hi,
Your question is extremely vague. Let's see an example of your CSV file and the script code you are using so far.
Bill
-
Wednesday, May 02, 2012 9:04 PM
My CSV file contains below value
COMPUTER1
COMPUTER2
COMPUTER3
COMPUTER4
These computer names are Domino server name and i need to replace these domino server names with windows name during the process. So that i can access the servers with windows name via the run window. So i hope you got the my requirment. Can you please help me. Thanks
-
Wednesday, May 02, 2012 9:19 PMModerator
Hi,
If the file is just a list of computer names without a header line, then it is not a CSV file. (CSV means "comma separated values"). So in this case you would use Get-Content rather than Import-Csv.
What does your script look like so far?
Bill
-
Thursday, May 03, 2012 1:34 PM
At this stage, the script is like below. The Inputfile contains Domino server Name.
$csv = Import-Csv Inputfile.csv -Header @("ServerName")
Foreach ($row in $csv)
{
$ServerName = $row.ServerName.........
.........
}
So at this stage, the $ServerName contains Domino Server Name from this Domino server name i need to find Windows name for that server and i need to get input of this windows name (if i ping Domino Server name i can get Windows name but i don't know how can i take input of that windows name). Please help me to fix this issue through powershell command.
-
Thursday, May 03, 2012 2:16 PMModerator
So at this stage, the $ServerName contains Domino Server Name from this Domino server name i need to find Windows name for that server and i need to get input of this windows name (if i ping Domino Server name i can get Windows name but i don't know how can i take input of that windows name). Please help me to fix this issue through powershell command.
Hi,
What do "find Windows name for that server" and "get input of this windows name" mean?
Bill
-
Thursday, May 03, 2012 2:31 PM
Actually Domino server Name is different and Windows server name is different for one particular server. We can RDP the particular server either by Domino server and as well as using WIndows server name. So in my inputfile contains Domino server name i want to convert that into Windows server name. once i converted then i need to process further with that windows name to complete my requirement.
C:\Users\chinnsx5>ping sanppt110
Pinging pd1900187.domain.com [10.258.169.13] with 32 bytes of data:
Reply from 10.258.169.13: bytes=32 time=2ms TTL=125
Reply from 10.258.169.13: bytes=32 time=1ms TTL=125
Reply from 10.258.169.13: bytes=32 time<1ms TTL=125
Reply from 10.258.169.13: bytes=32 time=1ms TTL=125In that SANPPT110 is a Domino server name and PD1900187 is Windows server name. So i hope you got my point.
-
Thursday, May 03, 2012 2:41 PMModerator
Hi,
I am guessing that your DNS server has alias records for the Domino server names that point to the actual Windows host names. So you could do something like the following:
PS C:\> [System.Net.Dns]::GetHostByName("sanppt110") | select-object -expandproperty HostName pd1900187.domain.comBill
- Marked As Answer by Bab_83 Thursday, May 03, 2012 3:05 PM

