powershell - Get-ADDomain | Select Name -
i making script supposed go server, grabbing domain name , users in specific group, go out , continue on next server. well, got connection phase done , need users , domain name. here snippet of code:
foreach ($user in (get-adgroupmember fjärrskrivbordsanvändare | select name)) { $userarray += $user.name $domainarray = get-addomain | select name $domainarray $userarray }
as can see add names of users in array, want save name of domain in array , print them both see if ok. when print domains, name show along ip server , code dont know comes from. looks this
cstein (ip) 82ddgfhdghjdfw-sdfgsbbc-42sfdsdf4-a8dfgd-734ddeee345817
does know fix this? want "cstein" when select name.
i scrambled numbers , letters in long "code" or whatever is. don't know if it's sensitive information.
keep in mind talkig swedish 15 year old when write answer.
i create pscustomobject
containing user
, domain
property:
$result = get-adgroupmember fjärrskrivbordsanvändare | foreach { [pscustomobject]@{ user = $_.name domain = get-addomain | select name } }
now can retrieve user names using:
$result | select user
note: don't want call get-addomain
each time within foreach...
Comments
Post a Comment