This was the final project of my March PowerShell class in Portland Maine. This is the “Real World” task that the class brought in. They needed to be able to specify OU in which code would be sent to each client based on the model number of that client. Below is the code. To run it, dot source it into your PowerShell session and to a Get-Help Send-Code –Full command to learn how to use it. I left a final challenge in the NOTES filed for the class. Function Get-ComputerList { Param ( [Parameter(Mandatory = $True )] $OUName ) # Get the target OU Object from AD. $OUName = " * " + $OUName + " * " $TargetOU = Get-ADObject -filter ' Name -like $OUName ' # Build a list of clients to target. $TargetObject = @() $Computers = Get-ADComputer -filter * -SearchBase $TargetOU ForEach ( $Computer in $Computers ) { $Obj = New-Object PSObject $Obj | Add-Member
Welcome to the blogsite of MCTExpert. I am a Microsoft Certified Trainer. Here you will find the real questions that are asked to me by my students.