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

Azure MFA with Azure AD and RDS

WIMMount (HSM) causing cluster storage to go redirected (2012r2 DC)

Failed to delete the test record dcdiag-test-record in zone test.com