Skip to main content

Posts

Showing posts from March, 2012

Send code to machines based on their OU and Model number with PowerShell

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...

Problem using Invoke-Command with Windows 7 client

While testing some code that used PowerShells Invoke-Command to send code to both Windows Server 2008 R2 and Windows 7, I discovered an inconsistency in the way Windows Remoting is applied to both platforms. The servers worked fine.  Even though I disabled to firewall for testing, I received this error when sending commands to the Windows 7 client:   [ClientName] Connecting to remote server failed with the following error message : The client cannot connect to the destingatoin specified in the request.  Verify that the service on the destination is running and is accepting requests.  Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM.  If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service” winrm quickconfig”.  For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo   ...