Welcome to Powergui.org - an open source community for Windows Powershell

PowerGUI.org PowerGUI.org and blogs

Forums » Request a Script

Thread: Script Request: AD Computer Objects Manager

This question is not answered. Helpful answers available: 2. Answered answers available: 1.


Permlink Replies: 2 - Pages: 1 - Last Post: Oct 11, 2007 12:56 PM by: BSonPosh
Ben Derry

Posts: 1
Registered: 10/9/07
Script Request: AD Computer Objects Manager
Posted: Oct 9, 2007 3:10 PM
 
  Click to reply to this thread Reply

I need a script that polls AD for Computer Objects then with that list it pings them by name. If the pings fail then move that Computer Object to a Different OU that I would check and clean out myself.

Thanks,
Ben


Dmitry Sotnikov


Posts: 1,151
Registered: 12/1/06
Re: Script Request: AD Computer Objects Manager
Posted: Oct 10, 2007 7:43 AM   in response to: Ben Derry
 
  Click to reply to this thread Reply

Ben,

This one worked for me:

Get-QADComputer | where { -not (Test-Port($_.Name)) } | Move-QADObject -NewParentContainer ps64.local/Recycled

Note that it uses Brandon's Test-Port function which he posted here: http://bsonposh.com/modules/wordpress/?p=45

Dmitry

See also: Dmitry's PowerBlog at http://dmitrysotnikov.wordpress.com


BSonPosh

Posts: 10
Registered: 10/11/07
Re: Script Request: AD Computer Objects Manager
Posted: Oct 11, 2007 12:56 PM   in response to: Dmitry Sotnikov
 
  Click to reply to this thread Reply

While I appreciate the trackback, I should warn that Test-Port isn't really a ping. It just makes a TCP Socket connection to a given port (135 RPC by default.) If you want a ping I use the function below for that. It is an actual ICMP ping. Test-Port is great if your company blocks pings or you want to specify a timeout, also the port is configurable.


function Ping-Server {
  Param([string]$server)
  $pingresult = Get-WmiObject win32_pingstatus -f "address='$Server'"
  if($pingresult.statuscode -eq 0) {$true} else {$false}
}




Legend
MVP: 2501 + pts
Guru: 2001 - 2500 pts
Expert: 751 - 2000 pts
Enthusiast: 31 - 750 pts
Novice: 0 - 30 pts
Moderators
Helpful answer (5 pts)
Answered (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums