Using $_. in write-host...how to narrow results


i have string @ end of series of if statements (adding users ad groups):

 else {write-host "user $_. not found in domain." -foregroundcolor yellow}

 works expected, object vaiable inserts all info path user account:

 user=usernamehere; mail=email@here.com; group1=mygroup...etc

i think i should able give me  the username, don't know how define obnject variable more specifcally. tried things $_.user , $_.logonname without sucess.

i acutally able resolve on own :)
turns out seeing $_. part of text string. breaking string in half , stiching + $_.user + got work:

write-host

 

 

 

("user "+ $_.user + " not found in domain.") -foregroundcolor yellow


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Generating Event ID 91, 44 with CA (In Event Viewer with source as Certsvc)

Group policy default policy cannot be edited because network name not found

Problem when changing update source