26 April 2013
Sharing multiple folders
net share command can be used to share folders and grant permissions
for ($i=1; $i -le 100; $i++){
$share = 'T' +$i
$user= 'ST_Samba.T' + $i
net share $share=E:\Software\$share "/grant:$user,full"
}
16 April 2013
Remove spaces from distribution group alias
$groups = Get-ADGroup -Filter * -Properties mailNickname
foreach ($grup in $groups){
Set-ADGroup -Identity $grup -Replace @{mailnickname=($grup.mailnickname.Replace(' ',''))} -Credential $cred -PassThru
}
08 April 2013
Query active directory with dsquery
dsquery can be used to retrieve any active directory attribute or filter for any active directory attribute using LDAP filter;
Ex: find user with employeeid=1234
dsquery * -filter (employeeid=1234) -attr attribute_name
to retrieve all active directory attribute user star (-attr *);
03 April 2013
Find all domain controllers in domain
Using powershell one can find all domain controllers in domain using:
1. a LDAP filter:
Get-ADComputer -LDAPFilter "(&(objectCategory=computer)(userAccountControl:1.2.840.113556.1.4.803:=8192))"
2. "Domain controllers" group and retreive his memebers:
Get-ADGroupMember 'Domain Controllers'
3. Get-ADDomainController cmdlet:
Get-ADDomainController -Filter * | Select-Object name
Subscribe to:
Posts (Atom)