Beruflich Dokumente
Kultur Dokumente
Get-Help Get-Command Get-Help Get-Command -detailed Get-Help Get-Command -Full Using an OBJ $DNSObj=Get-Service DNS $DNSObj.Status
Get-Service | Where {$_.status -eq "Running"} (alias of the above cmdlet) Checking the alias of dir cmd alias dir -----> Displays Get-Children
Power Shell Method $out=[adsi](LDAP://cn=users,dc=rit,dc=com) $ab=$out.Create(user,cn=u1) $ab.put(sAMAccountname,u1) ;$ab.put(useraccountcontrol,4130) $ab.SetInfo() {4130-user acc will be enabled 4128-------------------- disabled(default)}
or $ab.PSBase.InvokeSet('AccountDisabled',$true or $false) $ab.SetInfo() To edit the properties of a user object $Objusr=[ADSI]"LDAP://CN=Naveen Krishna,OU=OU1,DC=IT,DC=NET" $Objusr.Put("SN",'Krishna') $Objusr.Put("UserPrincipalName",'naveen.krishna@it.net') $Objusr.SetInfo()
To view all the attributes supported by an obj $Objusr | Get-Member or $Objusr.PSbase.Properties TO View a particular attribite $Objusr.Get("sAMAccountName") To enable the account $out=[adsi](LDAP://cn=u1,cn=users,dc=rit,dc=com) $out.psbase.InvokeSet(accountdisabled,$false) $out.SetInfo() To set password to a account $out=[adsi](LDAP://cn=u1,cn=users,dc=rit,dc=com) $out.SetPassword(rit-123) To force the user to change the pwd at next Logon $out=[adsi](LDAP://cn=u1,cn=users,dc=rit,dc=com) $out.Put("PwdLastSet",0) $out.SetInfo() To Change the CN of an obj $ObjUsr=[ADSI]"LDAP://cn=u1,cn=users,dc=rit,dc=com $ObjUsr.PSBase.Rename("CN=<New CN>") To Move a User $ObjUsr=[adsi](LDAP://CN=u1,CN=users,DC=rit,DC=com) #Connect to the User Obj $ObjUsr.PSBase.MoveTo("LDAP://OU=Ou,dc=rit,dc=com") #Specify TargetOU DN To Delete a User Account $ObjOu=[adsi](LDAP://cn=users,dc=rit,dc=com) #Connect to the Container/OU