-1

I am writing my first script in Powershell. I am using the command "Get-ADGroupMember xxx | select name".

When I type it in Powershell directly the ouput is a list:

name
----
User1
User2
User3

But when I use it in my script:

$Texto = Get-ADGroupMember xxx | select name
write-host = $Texto

The output is this:

$Texto = Get-ADGroupMember xxx | select name
write-host = $Texto
= @{name=User1} @{name=User2} @{name=User3}

how can I write this in my script so I can see it in a List?

Aragon
  • 11
  • Look up `-ExpandProperty` (so many questions about this) and `Write-Host` is a cmdlet, not a variable you can assign a value to with `=` – Theo May 12 '21 at 18:35

1 Answers1

0

Your $Texto is not a text, but rather an array of objects, which you can use for further processing. If you just wish to have the same output, just skip Write-Host and just refer to your variable directly, like so:

$Texto = Get-ADGroupMember xxx | select name
$Texto
raspy
  • 3,995
  • 1
  • 14
  • 18