Forgive the novice question, i’m new to powershell and am trying to do something which should be very easy!
i have a text file with the following contents
DEVICE ID: {E24CF707-F030-48DC-8E1A-59B96148BF52}
DEVICE NAME: All Devices (RAINBOW-SRV)
TYPE: Drive pool
DEVICE ID: {D16DC75F-8A8B-4AEC-A411-9B0BC58CBF16}
DEVICE NAME: HP 1
TYPE: Drive
DEVICE ID: {F2D2AB4A-1FBE-4158-AB62-6A94AE4392E2}
DEVICE NAME: RAINBOW-SRV
TYPE: Machine
DEVICE ID: {23AD5D42-00A8-496B-96E5-1F5CAA3F9E9D}
DEVICE NAME: Symantec Protection Network (RAINBOW-SRV)
TYPE: Symantec Protection Network
RETURN VALUE: 1
I’m trying to get the string that follows DEVICE NAME: on each occurence into an array to pass to a command further down the line. I’ve tried the following code but get an error stating that Substring is not a valid method.
I feel i’m missing something very obvious but cannot see it! any help would be much appreciated.
Many Thanks
Read the file content, filter the lines that begins with ‘DEVICE NAME: ‘, for each line remove (replace with nothing) ‘DEVICE NAME: ‘
UPDATE: per OT request, how to pass the value to an executable command