Я пытаюсь разобрать текст между строками вывода.
Я пытался использовать -split и подстроку, но я не получаю правильный вывод
Вот входной файл / значения конвейера
Please remove the following Roles:
Role1
Role2
Please remove the following Groups:
Groups1
Groups2
Please remove the following Profiles:
Profiles1
Profiles3
Profiles8
Please remove the following DGroups:
DG1
DG9
DG12
Вот код, который я пробовал
Foreach($input in $file){
#I’ve tried the split and I get too much data after roles
write-host $input.split(':')[1]
#replace gives me too much info after roles
$input.replace('Please remove the following Roles:','')
#this loop will continuously run
do{
$input}
until{$input.contains("please*")}
}
Я ожидаю, что результат выдаст мне Role1 и Role2, затем groups1 и groups2, затем profile1 и profile3 и profile8, затем dg1 и dg9 и dg12, а затем проигнорируют остальные.
У меня проблема в цикле do, я получаю непрерывный цикл.
В замен я получаю роли, но я также получаю строку удаления групп.