Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param($searchstr)
- $list=@()
- foreach($comp in Get-ADComputer -Filter "Name -like '*$searchstr*'"){
- if(test-connection -computername $comp.name -count 1 -ErrorAction SilentlyContinue){
- $obj = New-Object System.Object
- $obj | add-member -type NoteProperty -Name Computername -Value $comp.name
- $obj | add-member -type NoteProperty -Name User -Value (gwmi win32_computersystem -ComputerName $comp.name | Select-Object Username -ErrorAction SilentlyContinue).username
- $list+=$obj
- }
- }
- return $list | Format-table -AutoSize -HideTableHeaders
Advertisement
Add Comment
Please, Sign In to add comment