Author Posts

April 24, 2016 at 10:43 pm

I have a csv file, which has information like below (columns):
Name Datastore Folder
DSFPRDDB18_Replica dr-lun11-APP-vm VM
DSFPRDAPP182_Replica dr-lun16-APP-vm,dr-lun207-DB-vm VM

I wrote a .vbs script, but it is not working as expected. I am looking a for a powershell script which can will give me desired output.

I am looking for (ex: name has PRD, datastore has APP & name had DB, datastore has PRD, it should mail information. Same way, it should go through complete .CSV file and give me the output. If all the fields are mapped correclty, it should say: ALL GOOD.

.vbs script what I wrote:
strExcelPath = "C:\Opscripts\Kalyan\Vranger_Scripts\Lun_Check\Lun_Mapping_Wrong.csv"
set objexcel= createobject("Excel.Application")
Set objWorkBook=objExcel.WorkBooks.Open(strExcelPath)

intRow= objWorkBook.Worksheets(1).UsedRange.Rows.count
objWorkBook.Worksheets(1).cells(1,4) = "Results"
objexcel.DisplayAlerts =false

'To get the Column Values of the Fields
For i = 1 to intRow
if (instr(ucase(objWorkBook.Worksheets(1).Cells(i, 1)),"APP") and instr(ucase(objWorkBook.Worksheets(1).Cells(i, 2)),"DB")) Then
objWorkBook.Worksheets(1).Cells(i, 4) = "Error. Please check"
End if

if (instr(ucase(objWorkBook.Worksheets(1).Cells(i, 1)),"DB") and instr(ucase(objWorkBook.Worksheets(1).Cells(i, 2)),"APP")) Then
objWorkBook.Worksheets(1).Cells(i, 4) = "Error. Please check"
End If
Set objexcel = nothing


April 25, 2016 at 5:20 am

Show what you've tried in powershell and what is not working and we can try and help out. If you have not tried in powershell, give it a shot first.

Here are some of the powershell cmdlets I believe would be very helpful for this effort:

May 5, 2016 at 11:58 pm

Thanks. It worked out.