hi friends
I am new to PowerShell and i am studying hard since I've found it excellent to automate administrative tasks in my network.
I am trying to write an script which checks if ADDS service (which its service name is NTDS) exist & also if it is running, then my command which creates a set of objects in AD be executed (new-ADobject …….)
I am familiar with get-service Cmdlet & also with basic "if statement", which is
if (my condition) {
do stuff
}
but I don't know how to combine these things to make the final code.
I tested this code but I know it's properly wrong code:
$myservice =get-service -name NTDS |select status
if($myservice -eq "running"){
New-ADObject.......
}
may someone please write me the correct code
thanks a lot