Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Get OS of system from AD and add it to a group.

$
0
0

Hi,

I want to Add all windows 8 and 8.1 machines to particular group. 

What i want to do is recursively search machines in AD for Win 8 or 8.1 OS and add them to group. 

This is the code i wrote but its not working

$group=Get-ADGroup Win8
Get-ADOrganizationalUnit -Filter {Name -like '*computers*'} | 
     ForEach-Object{
	Get-ADComputer -Filter * -Searchbase $_	
     } |
     ForEach-Object{
        Get-ADComputer -prop *| 
          select OperatingSystem
          $OS = OperatingSystem
          if ($OS -eq "*Windows 8*")
          {
            Add-ADGroupMember $group -Members $_
          }
     }


\m/


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>