Get-ADComputer -Filter * -SearchBase "OU=Systems,OU=Alex,DC=com,DC=cn
I can filter out all computer in the OU of Systems,
Get-ADComputer -Filter * -SearchBase “OU=Systems,OU=Alex,DC=com,DC=cn” | foreach {Test-WSMan -ComputerName $_.DNSHostName}
Then I know which computer is online.
Then I want to use new-pssession to create a session for every online computer only.
but how to do that in the pile after I test the computer. I want to complete my request in one line by using pile.
I also want to add the DNSHostName to an additional text file for the on line computer by using > textfile.txt after test-wsman
any good idea ?