POwershell i paramtry SFU#

Po walcę z grupami w linuxie, pora przyszła aby przejrzeć AD.

Jak się okazało, nie wszystkie grupy windowsowe miały odpowiednie parametry więc pora była na dopisanie tych paramtrów.

Z tego powodu narodził sie ponizszy skrypt:

$strRoot = "LDAP://dc=pjwstk,dc=edu,dc=pl"
$Root = New-Object DirectoryServices.DirectoryEntry $strROOT
$Searcher = New-Object DirectoryServices.DirectorySearcher
$Searcher.SearchRoot = $root
$searcher.Filter = "(&(objectClass=Group))"
$groups = $searcher.findAll();

#get groups with no mssfu30name
foreach ($group in $groups) { if (!$group.Properties.mssfu30name) {write-host $group.Properties.name }}
#print maxgid
foreach ($group in $groups) { if ($group.Properties.mssfu30name) {write-host $group.Properties.mssfu30gidnumber }}
#setMaxgid

$maxgid=0
foreach ($group in $groups)
{
if ($group.Properties.mssfu30gidnumber)
{
$tmp = [int] $group.Properties.mssfu30gidnumber[0]
if ($tmp -gt $maxgid )
{
$maxgid=$tmp;
}
}
};

#set params
foreach ($group in $groups)
{
if (!$group.Properties.mssfu30gidnumber)
{
$maxgid= $maxgid+1
$de = new-object DirectoryServices.DirectoryEntry($group.Path)
$deName=$de.InvokeGet("cn");
$de.InvokeSet("mssfu30name",[string]$deName)
$de.InvokeSet("mssfu30gidnumber",[int]$maxgid)
$de.InvokeSet("mssfu30nisdomain",[string]"pjwstk")
$de.CommitChanges()
$de.close()
}
};



Tuesday, May 16, 2006 6:56:21 PM (Central European Standard Time, UTC+01:00) #    Comments [0]  |  Trackback

 

Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview
All content © 2010, Krzysztof Pietrzak
On this page
This site
Calendar
<July 2010>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
Archives
Sitemap
Blogroll OPML
  Tokyo by night
blog WiTa
  W-Files
blog n€x¤Ra
 .:fotoblog:.
blog Kfaza
 \\archon\blog$
blog archona
 Czasowstrzymywacz
Blog Fookyego
 Jog Pstryka
Jog Pstryka
 Mac OS X vs. Active Directory
techniczny blog kfaza

Maps
Locations of visitors to this page