Hi Guys,
I'm new in here, so I hope I've placed the question under the right section - otherwise let me know where to repost it.
My problem is that I'm trying to make a powershell script I can run from a Domain Controller and then push out a Static Route to all our servers that are placed in an OU in our AD.
Can someone spot what I'm doing wrong here, in order to make it work?
Import-module activedirectory
$=get-adcomputer -filter * -searchbase "OU=ITComputerObjects,OU=TestOU,DC=XXXXX,DC=tc"|
ForEach-Object{
$newProc=([WMICLASS]"\\$_\root\cimv2:win32_Process").Create('c:\windows\system32\cmd.exe /C route -p ADD 10.101.0.0 MASK 255.255.0.0 172.18.0.2 metric 2')
if($newproc.ReturnValue -ne 0){Write-Host "Creating process on $($_) failed"}
}
The whole idea is that the script should look into the OU i've specified, then for each object inside the OU it should run the newProc and open CMD and then like a normal command put in the details for the above route and then move on to the next object in the OU - and of course at every object let me know if it fails.
Thanks guys,
Edited by YoinkZ, 19 January 2016 - 03:51 AM.