Active Directory Tasks by using Powershell

Create OU
$strCL="organizationalUnit"
$strOUName="ou=TestOU"
$objADSI=[ADSI]"LDAP://dc=fabrikam,dc=com"
$objOU=$objADSI.create($strCL,$strOUName)
$objOU.setinfo()

Create User
$strCL="User"
$strName="Cn=Erkan"
$objADSI=[ADSI]"LDAP://ou=TestOU,dc=fabrikam,dc=com"
$objUser=$objADSI.create($strCL,$strName)
$$objUser.Put("sAMAccountName","Erkan")
$objUser.setinfo()

Modify User Properties

$objUser=[ADSI]"LDAP://cn=Erkan,ou=TestOU,dc=fabrikam,dc=com"
$objUser.put("sAMAccountName","Erkan")
$objUser.put("givenName","Sezgin")
$objUser.put("DisplayName","Erkan Sezgin")
$objUser.put("telephoneNumber","216-111-1111")
$objUser.put("mail","erkan.sezgin@fabrikam.com")
$objUser.setinfo()

Other Attributes;
wwwHomePage,description,streetAddress,postOfficeBox,l,st,postalcode,CountryCode
homeDirectory,homeDrive,profilePath,scriptPath,homePhone,title

put what you want,but dont forget the $setinfo() method at the end.

display registry key with Powershell

Get-ItemProperty HKLM:\Software\Microsoft

find last logged on user with Powershell

You can find the last logged on user to any computer

Get-wmiobject Win32_ComputerSystem -Comp "."

If you would,format your result by adding "| Select Name,Username" command.