Archive for category ete
Getting VMware Data Storages FreeSpace with percent as CSV file on VMware vSphere PowerCLI
Posted by cemguneyli in ete, Virt-vmware on May 23, 2011
If you need Data Storage free space of on your Vmware infrastructure (vSphere) as a Excel format ! Solution is here. I just need this information to follow my data growth in monthly or weekly. As you all know VMware does not provide this information like performans chart.
So just install VMware PowerCLI over here then write following script in a .ps1 file and save as getdatastorestatusascsv.ps1 via notepad or other text editor. Open Vmware PowerCLI on your desktop and just run it wherever you saved. Like “.getdatastorestatusascsv.ps1”
Do not forget determine csv file path, your Virtual Center IP address or DNS name, Username and Password for connect to Virtual Center in script.
example:
Connect-VIServer -server 192.168.1.1 -protocol https -user administrator -password Pwesd42#3
Script:
Connect-VIServer -server %VCServerIPorDNSName% -protocol https -user %USERNAME% -password %PASSWORD%
$file=”c:DataStoreStatus.csv”
$GetInfoDataSt = Get-Datastore | Sort-Object Name
$DataStorages = @()
foreach ($stores in $GetInfoDataSt )
{
$stor = “” | Select-Object Name, CapacityGB, UsedGB, FreeGB, PercentUse
$stor.Name = $stores.name
$stor.CapacityGB = [math]::Round($stores.CapacityMB/1024,2)
$stor.UsedGB = [math]::Round(($stores.CapacityMB – $stores.FreeSpaceMB)/1024,2)
$stor.FreeGB = $stor.CapacityGB – $stor.UsedGB
$stor.PercentUse = [math]::Round(100*$stores.FreeSpaceMB/$stores.CapacityMB,2)
$stor.PercentUse = 100 – $stor.PercentUse
$DataStorages += $stor
}
$DataStorages | Export-csv -Path $file
Search,Enable or Disable user/computer accounts in Active Directory over Web page (LDAP ASP)
Posted by cemguneyli in ete, Microsoft, System on May 11, 2011
through this code/ASP in below/file, you can search users,computers, printers and other objects in Active directory over web page, as a result of this search, you can get object’s location in AD. You can enable and disable the user/computer accounts of this page in Active Directory. Also You’ll able to move accounts into a Organization Unit when disable or enable accounts. (you can set different Organization Unit for Enable and Disable process). I mean you can collect disabled user/computer accounts into one Organization Unit or separated OUs.
To publish this ASP page over web site in IIS 6 or 7,ASP page need administrative privilege for working but for search just need authorized users. So at least ISS default authentication method should be change to basic authentication. For prevent unauthorized user to disable/enable accounts in Active Directory.
You can download ASP file here
source : http://www.emrullahekmekci.com.tr/?p=400
<%
‘
‘ 10 / 05 /2011 — Emrullah Tahir Ekmekçi
‘ Search, Enable or Disable Users and Computer account in Active Directory over Web browser
‘ 1.0
response.charset=”windows-1254″
Response.CacheControl = “no-cache”
response.Clear()
%>
<title>Search/Enable/Disable Users/Computers Accounts</title>
<body>
<br>
<br>
<center><form id=”form1″ name=”form1″ method=”post” action=”ADAramaAcmaKapama.asp”>
<label>User/Computer name
<input name=”is” type=”hidden” value=”is” /><input type=”text” name=”uname” id=”uname” />
</label>
</form></center>
</body>
</html>
<%
Dim strCN, objRootDSE, strDNSDomain, adoCommand, adoConnection
Dim strBase, strFilter, strAttributes, strQuery, adoRecordset
Dim strDN, strDisplay, strObjectCategory, intIndex
‘ Kullanici ve Bilgisayar hesabi acma ve kapatma
if request(“hesap”) <> “” and request(“y”) <> “” and request(“t”) <> “” then
strCN = request(“hesap”)
ka = request(“y”)
Set objRootDSE = GetObject(“LDAP://RootDSE”)
strDNSDomain = objRootDSE.Get(“defaultNamingContext”)
Set adoCommand = CreateObject(“ADODB.Command”)
Set adoConnection = CreateObject(“ADODB.Connection”)
adoConnection.Provider = “ADsDSOObject”
adoConnection.Open “Active Directory Provider”
adoCommand.ActiveConnection = adoConnection
strBase = “<LDAP://” & strDNSDomain & “>”
strFilter = “(cn=” & strCN & “*)”
strAttributes = “cn,distinguishedName,sAMAccountName,name,userAccountControl”
strQuery = strBase & “;” & strFilter & “;” & strAttributes & “;subtree”
adoCommand.CommandText = strQuery
adoCommand.Properties(“Page Size”) = 100
adoCommand.Properties(“Timeout”) = 30
adoCommand.Properties(“Cache Results”) = False
Set adoRecordset = adoCommand.Execute
Const ADS_UF_ACCOUNTDISABLE = 2
Set objUser = GetObject (“LDAP://” & adoRecordset.Fields(“distinguishedName”))
strOUDN = “OU=DisabledComputers,DC=fabrikam,DC=com” ‘ Disabled computers account will be moved this ou
strOUDNE = “CN=Computers,DC=fabrikam,DC=com” ‘ Enabled computers account will be moved this ou
strOUDNU = “OU=DisabledComputers,DC=fabrikam,DC=com” ‘Disabled users account will be moved this ou
strOUDNEU = “CN=Users,DC=fabrikami,DC=com” ‘ Enabled users account will be moved this ou
intUAC = objUser.Get(“userAccountControl”)
if ka = “k” then
if request(“t”) = “u” then
Set objOU = GetObject(“LDAP://” & strOUDNU)
objUser.Put “userAccountControl”, intUAC OR ADS_UF_ACCOUNTDISABLE ‘ User account is closed.
objUser.SetInfo
objOU.movehere objUser.ADsPath, objUser.name ‘ User account is moving.
end if
if request(“t”) = “b” then
Set objOU = GetObject(“LDAP://” & strOUDN)
objUser.accountdisabled = true ‘ Computer account is closed.
objUser.SetInfo
objOU.movehere objUser.ADsPath, objUser.name ‘ Computer account is moving.
end if
response.write “Account has been closed”
elseif ka = “a” then
if request(“t”) = “u” then
Set objOU = GetObject(“LDAP://” & strOUDNEU)
objUser.Put “userAccountControl”, intUAC XOR ADS_UF_ACCOUNTDISABLE ‘ User account is open.
objUser.SetInfo
objOU.movehere objUser.ADsPath, objUser.name ‘ User account is moving.
end if
if request(“t”) = “b” then
Set objOU = GetObject(“LDAP://” & strOUDNE)
objUser.accountdisabled = false ‘ Computer account is open.
objUser.SetInfo
objOU.movehere objUser.ADsPath, objUser.name ‘Computer account is moving.
end if
response.write “Account has been opened”
end if
response.Redirect “ADAramaAcmaKapama.asp?uname=”&request(“hesap”)&”&is=1″
adoRecordset.Close
response.End()
end if
‘ object search
if request(“uname”) = “” and request(“is”) <> “” then
%><p><b><center>User/Computer name can not be empty.</center></b></font></p><%
elseif request(“uname”) <> “” and request(“is”) <> “” then
strCN = request(“uname”) & “*”
if len(strCN) <4 then
response.Clear()
Response.Write(“Please enter least 3 char.”)
Response.end
end if
Set objRootDSE = GetObject(“LDAP://RootDSE”)
strDNSDomain = objRootDSE.Get(“defaultNamingContext”)
Set adoCommand = CreateObject(“ADODB.Command”)
Set adoConnection = CreateObject(“ADODB.Connection”)
adoConnection.Provider = “ADsDSOObject”
adoConnection.Open “Active Directory Provider”
adoCommand.ActiveConnection = adoConnection
strBase = “<LDAP://” & strDNSDomain & “>”
strFilter = “(cn=” & strCN & “)”
strAttributes = “cn,distinguishedName,sAMAccountName,name,userAccountControl”
strQuery = strBase & “;” & strFilter & “;” & strAttributes & “;subtree”
adoCommand.CommandText = strQuery
adoCommand.Properties(“Page Size”) = 100
adoCommand.Properties(“Timeout”) = 30
adoCommand.Properties(“Cache Results”) = False
Set adoRecordset = adoCommand.Execute
If (adoRecordset.EOF = True) Then
Response.Write(“<center>No record found</center>”)
Response.end
End If
‘ Table has been created what is object will be show.
Response.Write(“<table width=100% height=100% ><tr width=100% height=100% ><td width=100% height=100% align=center valign=center><table border=’1′>”)
Response.Write(“<tr><th> Account Name </th><th> Computer/User name </th><th> Status</th><th> Type </th><th> DN </th></tr>”)
Response.Write(“<font size=-2>”)
Do Until adoRecordset.EOF
vSAMAccountName= adoRecordset.Fields(“sAMAccountName”).Value
vName = adoRecordset.Fields(“name”).Value
vUserAccountControl= adoRecordset.Fields(“userAccountControl”).Value
vDistinguishedName= adoRecordset.Fields(“distinguishedName”).Value
AKR = 0
if vUserAccountControl = 512 then
AKR = 1
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vSAMAccountName&”&y=k&t=u’ title=’Kapatmak için tiklayin’><center> Close</center> </a>”
elseif vUserAccountControl = 514 then
AKR = 0
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vSAMAccountName&”&y=a&t=u’ title=’Açmak için tiklayin’><center> Open </center></a>”
elseif vUserAccountControl = 544 then
AKR = 1
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vSAMAccountName&”&y=k&t=u’ title=’Kapatmak için tiklayin’><center> Close/ilsd </center></a>”
elseif vUserAccountControl = 66048 then
AKR = 1
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vSAMAccountName&”&y=k&t=u’ title=’Kapatmak için tiklayin’><center> Close/s </center></a>”
elseif vUserAccountControl = 66050 then
AKR = 0
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vSAMAccountName&”&y=a&t=u’ title=’Açmak için tiklayin’><center> Open/s </center></a>”
elseif vUserAccountControl = 4096 then
AKR = 1
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vName&”&y=k&t=b’ title=’Kapatmak için tiklayin’><center> Close </center></a>”
elseif vUserAccountControl = 4128 then
AKR = 1
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vName&”&y=k&t=b’ title=’Kapatmak için tiklayin’><center> Close </center></a>”
elseif vUserAccountControl = 4098 then
AKR = 0
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vName&”&y=a&t=b’ title=’Açmak için tiklayin’><center> Open </center></a>”
else
vUserAccountControlDesc = vUserAccountControl
end if
cuc = instr (vSAMAccountName,”$”)
if vUserAccountControl <> “” then
if cuc = 0 then Response.Write(“<tr><td> ” & vSAMAccountName & ” </td>”) else Response.Write(“<tr><td></td>”)
if AKR = 0 then
response.write (“<td style=’background-color: #FF0000′> “&vName&” </td>”)
else
response.write (“<td style=’background-color: #00FF00′> “&vName&” </td>”)
end if
if cuc = 0 then
Response.Write(“<td style=’background-color: #667C26′>” & ” User ” & “</td>”)
else
Response.Write(“<td style=’background-color: #4863A0′>”& ” Computer ” & “</td>”)
end if
Response.Write(“<td>” & vUserAccountControlDesc & ” </td>”)
Response.Write(“<td align=right > ” & vDistinguishedName & ” </td>”)
else
end if
Response.Write(“</td></tr>”)
adoRecordset.MoveNext
strDisplay = 1
Loop
adoRecordset.Close
if strDisplay = “” then Response.Write(“Can not be search —” & strDisplay & “—“)
adoConnection.Close
Response.Write(“</font>”)
Response.Write(“</table></td></tr></table>”)
Response.Write(“<br><align=left>P.S. :<br>Open/ilsd = Password will change first logon<br>Open/s = Password never expire<br>Close/s= Password never expire<br><br><br><br>”)
Response.End()
end if%>
Web’ten Active Directory’deki Kullanıcı ve Bilgisayar hesaplarını Enable/Disable yapılması (ASP ile)
Posted by cemguneyli in ete, Microsoft on May 10, 2011
Aşağıda ve linkte bulunan asp kodları/dosyası ile, Active Directory’deki kullanıcı ve bilgisayar hesapları arasında arama yapabilir, nesnelerin Active Directory içerisindeki yerini öğrenebilir ve kullanıcı ve bilgisayar hesaplarını kapatıp açabilirsiniz. Kapatılan kulanıcı ve bilgisayar hesaplarını istediğiniz OU’da toplayabilir veya açtıklarınızı istediğiniz OU ya taşıyabilirsiniz.
Bu ASP dosyasını çalışabilmesi yayınladığınız web sitesi için IIS yapılacak tek ayar ise ; web site’ın authentication method’unu Basic authentication yapmak, böylece yetkisiz kullanıcılar Active Directory’de arama yapabilecekler fakat, enable/disable veya nesne taşıması yapamıyacaklar.
Dosyayi buradan indirebilirsiniz
Kaynak : http://www.emrullahekmekci.com.tr/?p=379
<%
‘
‘ 10 / 05 /2011 — Emrullah Tahir Ekmekçi
‘ Kullanici ve Bilgisayar hesaplarinin web üzerinden Enable/Disable yapilmasi
‘ 1.0
response.charset=”windows-1254″
Response.CacheControl = “no-cache”
response.Clear()
%>
<title>Kullanici/Bilgisayar hesabi arama/acma/kapatma</title>
<body>
<br>
<br>
<center><form id=”form1″ name=”form1″ method=”post” action=”ADAramaAcmaKapama.asp”>
<label>Nesne adi
<input name=”is” type=”hidden” value=”is” /><input type=”text” name=”uname” id=”uname” />
</label>
</form></center>
</body>
</html>
<%
Dim strCN, objRootDSE, strDNSDomain, adoCommand, adoConnection
Dim strBase, strFilter, strAttributes, strQuery, adoRecordset
Dim strDN, strDisplay, strObjectCategory, intIndex
‘ Kullanici ve Bilgisayar hesabi acma ve kapatma
if request(“hesap”) <> “” and request(“y”) <> “” and request(“t”) <> “” then
strCN = request(“hesap”)
ka = request(“y”)
Set objRootDSE = GetObject(“LDAP://RootDSE”)
strDNSDomain = objRootDSE.Get(“defaultNamingContext”)
Set adoCommand = CreateObject(“ADODB.Command”)
Set adoConnection = CreateObject(“ADODB.Connection”)
adoConnection.Provider = “ADsDSOObject”
adoConnection.Open “Active Directory Provider”
adoCommand.ActiveConnection = adoConnection
strBase = “<LDAP://” & strDNSDomain & “>”
strFilter = “(cn=” & strCN & “*)”
strAttributes = “cn,distinguishedName,sAMAccountName,name,userAccountControl”
strQuery = strBase & “;” & strFilter & “;” & strAttributes & “;subtree”
adoCommand.CommandText = strQuery
adoCommand.Properties(“Page Size”) = 100
adoCommand.Properties(“Timeout”) = 30
adoCommand.Properties(“Cache Results”) = False
Set adoRecordset = adoCommand.Execute
Const ADS_UF_ACCOUNTDISABLE = 2
Set objUser = GetObject (“LDAP://” & adoRecordset.Fields(“distinguishedName”))
strOUDN = “OU=DisabledComputers,DC=fabrikam,DC=com” ‘ Kapatilan Bilgisayar Hesaplarinin tasinacagi OU
strOUDNE = “CN=Computers,DC=fabrikam,DC=com” ‘ Açilan Bilgisayar Hesaplarinin tasinacagi OU
strOUDNU = “OU=DisabledComputers,DC=fabrikam,DC=com” ‘Kapatilan kullanici Hesaplarinin tasinacagi OU
strOUDNEU = “CN=Users,DC=fabrikami,DC=com” ‘ Açilan Bilgisayar Hesaplarinin tasinacagi OU
intUAC = objUser.Get(“userAccountControl”)
if ka = “k” then
if request(“t”) = “u” then
Set objOU = GetObject(“LDAP://” & strOUDNU)
objUser.Put “userAccountControl”, intUAC OR ADS_UF_ACCOUNTDISABLE ‘ kullanici hesabi kapatiliyor
objUser.SetInfo
objOU.movehere objUser.ADsPath, objUser.name ‘ kullanici hesabi tasiniyor
end if
if request(“t”) = “b” then
Set objOU = GetObject(“LDAP://” & strOUDN)
objUser.accountdisabled = true ‘ bilgisayar hesabi kapatiliyor
objUser.SetInfo
objOU.movehere objUser.ADsPath, objUser.name ‘ bilgisayar hesabi tasiniyor
end if
response.write “Hesap Kapatildi”
elseif ka = “a” then
if request(“t”) = “u” then
Set objOU = GetObject(“LDAP://” & strOUDNEU)
objUser.Put “userAccountControl”, intUAC XOR ADS_UF_ACCOUNTDISABLE ‘ kullanici hesabi açiliyor
objUser.SetInfo
objOU.movehere objUser.ADsPath, objUser.name ‘ bilgisayar hesabi kapatiliyor
end if
if request(“t”) = “b” then
Set objOU = GetObject(“LDAP://” & strOUDNE)
objUser.accountdisabled = false ‘ bilgisayar hesabi açiliyor
objUser.SetInfo
objOU.movehere objUser.ADsPath, objUser.name ‘bilgisayar hesabi tasiniyor
end if
response.write “Hesap Acildi”
end if
response.Redirect “ADAramaAcmaKapama.asp?uname=”&request(“hesap”)&”&is=1″
adoRecordset.Close
response.End()
end if
‘ AD’de nesene aramari
if request(“uname”) = “” and request(“is”) <> “” then
%><p><b><center>Nesneyi bos gecmeyin lütfen.</center></b></font></p><%
elseif request(“uname”) <> “” and request(“is”) <> “” then
strCN = request(“uname”) & “*”
if len(strCN) <4 then
response.Clear()
Response.Write(“en az 3 karakter girmelisiniz.”)
Response.end
end if
Set objRootDSE = GetObject(“LDAP://RootDSE”)
strDNSDomain = objRootDSE.Get(“defaultNamingContext”)
Set adoCommand = CreateObject(“ADODB.Command”)
Set adoConnection = CreateObject(“ADODB.Connection”)
adoConnection.Provider = “ADsDSOObject”
adoConnection.Open “Active Directory Provider”
adoCommand.ActiveConnection = adoConnection
strBase = “<LDAP://” & strDNSDomain & “>”
strFilter = “(cn=” & strCN & “)”
strAttributes = “cn,distinguishedName,sAMAccountName,name,userAccountControl”
strQuery = strBase & “;” & strFilter & “;” & strAttributes & “;subtree”
adoCommand.CommandText = strQuery
adoCommand.Properties(“Page Size”) = 100
adoCommand.Properties(“Timeout”) = 30
adoCommand.Properties(“Cache Results”) = False
Set adoRecordset = adoCommand.Execute
If (adoRecordset.EOF = True) Then
Response.Write(“<center>Aradiginiz kriterde kayit bulunamadi</center>”)
Response.end
End If
‘ AD nesnelerinin gösterilecegi tablo olusturuluyor.
Response.Write(“<table width=100% height=100% ><tr width=100% height=100% ><td width=100% height=100% align=center valign=center><table border=’1′>”)
Response.Write(“<tr><th> Hesap adi </th><th> Bilgisayar/Kullanici Adi </th><th> Durum </th><th> Tipi </th><th> AD Yeri </th></tr>”)
Response.Write(“<font size=-3>”)
Do Until adoRecordset.EOF
vSAMAccountName= adoRecordset.Fields(“sAMAccountName”).Value
vName = adoRecordset.Fields(“name”).Value
vUserAccountControl= adoRecordset.Fields(“userAccountControl”).Value
vDistinguishedName= adoRecordset.Fields(“distinguishedName”).Value
AKR = 0
if vUserAccountControl = 512 then
AKR = 1
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vSAMAccountName&”&y=k&t=u’ title=’Kapatmak için tiklayin’><center> Kapat</center> </a>”
elseif vUserAccountControl = 514 then
AKR = 0
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vSAMAccountName&”&y=a&t=u’ title=’Açmak için tiklayin’><center> Aç </center></a>”
elseif vUserAccountControl = 544 then
AKR = 1
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vSAMAccountName&”&y=k&t=u’ title=’Kapatmak için tiklayin’><center> Kapat/ilsd </center></a>”
elseif vUserAccountControl = 66048 then
AKR = 1
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vSAMAccountName&”&y=k&t=u’ title=’Kapatmak için tiklayin’><center> Kapat/s </center></a>”
elseif vUserAccountControl = 66050 then
AKR = 0
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vSAMAccountName&”&y=a&t=u’ title=’Açmak için tiklayin’><center> Aç/s </center></a>”
elseif vUserAccountControl = 4096 then
AKR = 1
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vName&”&y=k&t=b’ title=’Kapatmak için tiklayin’><center> Kapat </center></a>”
elseif vUserAccountControl = 4128 then
AKR = 1
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vName&”&y=k&t=b’ title=’Kapatmak için tiklayin’><center> Kapat </center></a>”
elseif vUserAccountControl = 4098 then
AKR = 0
vUserAccountControlDesc = “<a href=’./ADAramaAcmaKapama.asp?hesap=”&vName&”&y=a&t=b’ title=’Açmak için tiklayin’><center> Aç </center></a>”
else
vUserAccountControlDesc = vUserAccountControl
end if
cuc = instr (vSAMAccountName,”$”) ‘ Nesnin Bilgisayar hesabini oldugunu belirten “$” karakteri kontrolu yapiliyor
if vUserAccountControl <> “” then
if cuc = 0 then Response.Write(“<tr><td> ” & vSAMAccountName & ” </td>”) else Response.Write(“<tr><td></td>”)
if AKR = 0 then
response.write (“<td style=’background-color: #FF0000′> “&vName&” </td>”)
else
response.write (“<td style=’background-color: #00FF00′> “&vName&” </td>”)
end if
if cuc = 0 then
Response.Write(“<td style=’background-color: #667C26′>” & ” Kullanici ” & “</td>”)
else
Response.Write(“<td style=’background-color: #4863A0’>”& ” Bilgisayar ” & “</td>”)
end if
Response.Write(“<td>” & vUserAccountControlDesc & ” </td>”)
Response.Write(“<td align=right > ” & vDistinguishedName & ” </td>”)
else
end if
Response.Write(“</td></tr>”)
adoRecordset.MoveNext
strDisplay = 1
Loop
adoRecordset.Close
if strDisplay = “” then Response.Write(“Arama yapilamadi —” & strDisplay & “—“)
adoConnection.Close
Response.Write(“</font>”)
Response.Write(“</table></td></tr></table>”)
Response.Write(“<br><align=left>Note :<br>Acik/ilsd = Ilk logon’da sifre degistirilecek<br>Acik/s = Süresis sifre<br>Kapali/s = Süresis sifre<br><br><br><br>”)
Response.End()
end if%>
Active Directory'deki Bilgisayar hesaplarının en son Logon zamanının alınması/listelenmesi (VBA, windows script)
Posted by cemguneyli in ete on May 4, 2011
Geçtiğimiz hafta, Active Diretory’de aktif olmayan (kullanılmayan) bilgisayar hesaplarının listesine ihtiyacım oldu. Bu bilgiyi Active Directory’den almak için çeşitli yollar kullanabilirdim fakat bunların bir çoğu oldukça meşakatli.
İnternette bu işlem için çeşitli Windows Script’ler var, ama hangisini ve nasıl kullancağım ? Üstelik elde ettiğim sonuçları text yada csv dosyasına nasıl aktaracağım ?
Sonuç olarak aşağıda linki bulunan uygulamayı geliştirdim (vba içerisinde windows script kullandım).
Bu uygulamada, ihtiyaç duyulabilecek basit 1 -2 seçenek ekleyerek kullanılabilirliğini de artırdım. Örneğin, bulunacak bilgisayarlar için zaman aralığı (son XX gündür logon olmayan bilgisayarlar) girilebiliyor ve bu bilgisayarları Active Diretory’de DN olarak belirttiğiniz yere taşıyabiliyor. Ayrıca Bilgisayar hesabının adını, son logon zamanını ve DN ini text dosyası olarak alabiliyorsunuz. (csv uyumlu, böylece excel’e kolaylıkla aktarabilirsiniz.)
Uygulamayı buradan indirebilirsiniz.
Not: Zip dosyasının şifresi “ete”
Getting Last Logon time for Computers in Domain as list with VBA
Posted by cemguneyli in Articles, ete, Microsoft on April 27, 2011
Last week, I need to find how many inactive computers in our Active Directory with computers name and last logon date. I can use this info various way after gather from our Active Directory.
There are lot of scripts about it in Internet but problem is which one should I use and how to! Also I need to export those computers as a text or csv file and how to move those computers in a Organization Unit in Active directory.
So I developed this application. I can gather/do whole this.
Application has some setting like you can set a Day period and set DN location in Active directory for where those computers account will moved.
Also Application has two language support, Turksih and English.
P.S. : Zip file password is “ete”
Gathering PCs info during logon progress
Posted by cemguneyli in Articles, ete, System on April 20, 2011
Whole data about your PC in Active Directory will automatically coming from PCs to wherevery you want. You should run this script via Login progress, I ment, use GPO, If you have any Question How/What/Where … , Just ask !
P.S. : Some codes have been obtained from the Internet.
link : http://www.emrullahekmekci.com.tr/2011/04/20/gathering-pcs-info-durining-login-progress/
' 20 / 04 /2011 -- Emrullah Tahir Ekmekçi
' user and computer data collection with Text file
' 1.1
On Error Resume Next ' If we do not get any or portion info from computer, will try again copy file for determine computer
' Gathered data will be copying this network path.
Targetpath = "172.28.202.164SharedSL"
'Temp Dir
Set objShell = CreateObject("Wscript.Shell")
TempDir = objShell.ExpandEnvironmentStrings("%temp%")
Set objShell = nothing
' Computer Name
set wshnetwork=createobject("wscript.network")
strComputer=wshnetwork.computername
set wshnetwork=nothing
filename = TempDir & "" & strComputer & ".txt"
SET objWMIDateTime = CREATEOBJECT("WbemScripting.SWbemDateTime")
SET objWMI = GETOBJECT("winmgmts:" & strComputer & "rootcimv2")
SET colOS = objWMI.InstancesOf("Win32_OperatingSystem")
' System Last Boot and Up date
FOR EACH objOS in colOS
objWMIDateTime.Value = objOS.LastBootUpTime
LBUT = objWMIDateTime.GetVarDate & vbcrlf & TimeSpan(objWMIDateTime.GetVarDate,NOW)
NEXT
' System Type // Systemtype options will be narrow after gather whole types
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
Set colChassis = objWMIService.ExecQuery _
("Select * from Win32_SystemEnclosure")
For Each objChassis in colChassis
For Each strChassisType in objChassis.ChassisTypes
Select Case strChassisType
Case 1 SystemType = "Other"
Case 2 SystemType = "Unknown"
Case 3 SystemType = "Desktop"
Case 4 SystemType = "Low Profile Desktop"
Case 5 SystemType = "Pizza Box"
Case 6 SystemType = "Mini Tower"
Case 7 SystemType = "Tower"
Case 8 SystemType = "Portable"
Case 9 SystemType = "Laptop"
Case 10 SystemType = "Notebook"
Case 11 SystemType = "Handheld"
Case 12 SystemType = "Docking Station"
Case 13 SystemType = "All-in-One"
Case 14 SystemType = "Sub-Notebook"
Case 15 SystemType = "Space Saving"
Case 16 SystemType = "Lunch Box"
Case 17 SystemType = "Main System Chassis"
Case 18 SystemType = "Expansion Chassis"
Case 19 SystemType = "Sub-Chassis"
Case 20 SystemType = "Bus Expansion Chassis"
Case 21 SystemType = "Peripheral Chassis"
Case 22 SystemType = "Storage Chassis"
Case 23 SystemType = "Rack Mount Chassis"
Case 24 SystemType = "Sealed-Case PC"
Case Else SystemType = "Unknown"
End Select
Next
Next
' very rare but sometimes Select Case could not get any data from strChassisType even "Case Else"
if SystemType = "" or SystemType = " " then
SystemType = "Unknown"
end if
' Windows installed date
Set dtmInstallDate = CreateObject("WbemScripting.SWbemDateTime")
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
dtmInstallDate.Value = objOperatingSystem.InstallDate
installd = dtmInstallDate.GetVarDate
Next
' Collect Computer Info
ComputerInfo = "[ComputerInfo]" & vbCrLf
ComputerInfo = ComputerInfo & strComputer & vbCrLf
ComputerInfo = ComputerInfo & TempDir & vbCrLf
ComputerInfo = ComputerInfo & LBUT & vbCrLf
ComputerInfo = ComputerInfo & SystemType & vbCrLf
ComputerInfo = ComputerInfo & installd & vbCrLf
' Username
Set colSoftware = objWMIService.ExecQuery ("SELECT * FROM Win32_Product")
Set objNetwork = CreateObject("WScript.Network")
Username = objNetwork.UserName
ComputerInfo = ComputerInfo & Username & vbCrLf
' Collect Members of Local Admin Groups
LocalAdminGroup = LocalAdminGroup & vbCrLf & "[LocalAdminGroup]" & vbCrLf
Set objComp = GetObject("WinNT://" & strComputer)
objComp.GetInfo
If objComp.PropertyCount > 0 Then
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
If objGroup.PropertyCount > 0 Then
For Each mem In objGroup.Members
LocalAdminGroup = LocalAdminGroup & Right(mem.adsPath,Len(mem.adsPath) - 8) & vbCrLf
Next
End If
End If
'Collect Operation System and CPU info
OsInfo = OsInfo & vbCrLf & "[OsInfo]" & vbCrLf
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colSettings
OsInfo = OsInfo & objOperatingSystem.Caption & vbCrLf
OsInfo = OsInfo & objOperatingSystem.RegisteredUser & vbCrLf
OsInfo = OsInfo & objOperatingSystem.ServicePackMajorVersion & vbCrLf
OsInfo = OsInfo & objOperatingSystem.ServicePackMinorVersion & vbCrLf
OsInfo = OsInfo & objOperatingSystem.Version & vbCrLf
Next
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings
OsInfo = OsInfo & objComputer.Manufacturer & vbCrLf
OsInfo = OsInfo & objComputer.Model & vbCrLf
OsInfo = OsInfo & objComputer.TotalPhysicalMemory /10241024+1 & vbCrLf
Next
Cpu = Cpu & vbCrLf & "[Cpu]" & vbCrLf
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem in colItems
Cpu = Cpu & objItem.Description & vbCrLf
Cpu = Cpu & objItem.Manufacturer & vbCrLf
Cpu = Cpu & objItem.MaxClockSpeed & vbCrLf
Cpu = Cpu & objItem.Name & vbCrLf
Next
' Collect Bios Info
bios = bios & vbCrLf & "[Bios]" & vbCrLf
Set colBIOS = objWMIService.ExecQuery ("Select * from Win32_BIOS")
For each objBIOS in colBIOS
bios =bios & objBIOS.Manufacturer & vbcrlf
bios =bios & objBIOS.Name & vbcrlf
bios =bios & objBIOS.ReleaseDate & vbcrlf
bios =bios & objBIOS.SerialNumber & vbcrlf
bios =bios & objBIOS.SMBIOSBIOSVersion & vbcrlf
bios =bios & objBIOS.SMBIOSMajorVersion & vbcrlf
bios =bios & objBIOS.SMBIOSMinorVersion & vbcrlf
bios =bios & objBIOS.Version & vbcrlf
Next
Basebord = Basebord & vbCrLf & "[Basebord]" & vbCrLf
Set objWMIService = GetObject("winmgmts:" & strComputer & "rootcimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BaseBoard")
For Each objItem in colItems
Basebord = Basebord & objItem.Manufacturer & vbcrlf
if objItem.Model = "" then
Basebord = Basebord & objItem.Model & vbcrlf
Else
Basebord = Basebord & "Veri Yok" & vbcrlf
end if
Basebord = Basebord & objItem.Product & vbcrlf
Basebord = Basebord & objItem.SerialNumber & vbcrlf
Next
' Collect Drivers info
disk = disk & vbCrLf & "[Disk]" & vbCrLf
Set colItems = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")
For Each objItem in colItems
if objItem.Name <> "" then disk = disk & objItem.Name & vbCrlf
if objItem.Description <> "" then disk = disk & objItem.Description & vbCrlf
disk = disk & objItem.VolumeName & vbCrlf
if objItem.VolumeSerialNumber <> "" then disk = disk & objItem.VolumeSerialNumber & vbCrlf
if objItem.Size <> "" then disk = disk & Int(objItem.Size /1073741824) & vbCrlf
if objItem.FreeSpace <> "" then disk = disk & Int(objItem.FreeSpace /1073741824) & vbCrlf & vbCrlf else disk = disk & vbCrlf
Next
' Collect Modems info
modem = modem & vbCrLf & "[Modem]" & vbCrLf
Set colItems = objWMIService.ExecQuery("Select * from Win32_POTSModem")
For Each objItem in colItems
modem = modem & objItem.AttachedTo & vbcrlf
modem = modem & objItem.DeviceType & vbcrlf
modem = modem & objItem.Model & vbcrlf & vbcrlf
Next
' Collect Network Cards info
Networkb = Networkb & vbCrLf & "[Network]" & vbCrLf
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration")
For Each objItem In colItems
For Each objValue In objItem.IPAddress
If objValue <> "" Then
Networkb = Networkb & objItem.Description & vbcrlf & objValue & vbcrlf & objItem.MACAddress & vbcrlf
End If
Next
Next
' Collect Installed Apps
Apps = Apps & vbCrLf & "[Apps]" & vbCrLf
If colSoftware.Count > 0 Then
For Each objSoftware in colSoftware
Apps = Apps & objSoftware.Caption & vbtab & objSoftware.Version & vbCrLf
Next
End If
' Collect Services info
Set cInstances = GetObject("winmgmts:{impersonationLevel=impersonate}//" &_
strComputer & "/root/cimv2:Win32_Service").Instances_
svrc = svrc & vbCrLf & "[Services]" & vbCrLf
For Each oInstance In cInstances
svrc= svrc & oInstance.Properties_("DisplayName").Value & vbTab & oInstance.Properties_("StartMode").Value & vbTab & oInstance.Properties_("State").Value & vbCrLf
Next
' Collect Installed Microsft Updates
Updates = Updates & vbCrLf & "[Updates]" & vbCrLf
Set objSession = CreateObject("Microsoft.Update.Session", strComputer)
If Err.Number <> 0 Then
Set objSearcher = objSession.CreateUpdateSearcher
intHistoryCount = objSearcher.GetTotalHistoryCount
Set colHistory = objSearcher.QueryHistory(1, intHistoryCount)
For Each objEntry in colHistory
Set objIdentity = objEntry.UpdateIdentity
Updates = Updates & objEntry.Date & vbtab & objEntry.Title & vbcrlf
Next
End If
Report = ComputerInfo & LocalAdminGroup & OsInfo & Cpu & Bios & Basebord & Disk & Modem & Networkb & Apps & svrc & Updates
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile( filename , True)
objTextFile.WriteLine Report
objTextFile.Close
Set FSO =CreateObject("scripting.FileSystemObject")
if FSO.FileExists (filename) then
FSO.CopyFile filename ,Targetpath , True
end if
SET objWMIDateTime = Nothing
SET objWMI = Nothing
SET colOS = Nothing
Set objWMIService = Nothing
Set colChassis = Nothing
Set dtmInstallDate = Nothing
Set colOperatingSystems = Nothing
Set colSoftware = Nothing
Set objNetwork = Nothing
Set objComp = Nothing
Set colSettings = Nothing
Set colItems = Nothing
Set colBIOS = Nothing
Set objFSO = Nothing
Set objTextFile = Nothing
Set FSO = Nothing
Set objSearcher = Nothing
Set colHistory = Nothing
Set objIdentity = Nothing
FUNCTION TimeSpan(dt1, dt2)
IF (ISDATE(dt1) AND ISDATE(dt2)) = FALSE THEN
TimeSpan = "00:00:00"
EXIT FUNCTION
END IF
seconds = ABS(DATEDIFF("S", dt1, dt2))
minutes = seconds 60
hours = minutes 60
minutes = minutes MOD 60
seconds = seconds MOD 60
IF LEN(hours) = 1 THEN hours = "0" & hours
TimeSpan = hours & ":" & _
RIGHT("00" & minutes, 2) & ":" & _
RIGHT("00" & seconds, 2)
END FUNCTION
Putty ile SSH tünel yaparak Internet erişimi
Posted by cemguneyli in Articles, ete, System on March 14, 2011
Neden SSH tünel üzerinden Internet erişimine ihtiyacımız olabilir ? Aslında bu makale genel kullanıcılardan ziyade müşterilerde hizmet veren Sistem Yöneticilerine daha çok hitap ediyor. Çünkü Sistem Yöneticileri zaman zaman buna ihtiyaçları oluyor.
Söyleki; müşteridesiniz ve haliyle internet’e ihtiyacınız var, şüphesiz ki size internet erişimi sağlanmakta. Bazı işletmelerde bu erişim işletmenin internet erişim politikası yüzünden kısıtlı olmakta, işletme URL filitreleme veya içerik filitreleme yazılımları kullanıyor ise istediğiniz web adreslerine erişmekte sıkıntı olabiliyor.
Putty’i kullanarak SSH tünel ile internete eriştiğinizde ise işletmenin uyguladığı bu kısıtlamara takılmıyorsunuz ayrıca SSH ile bağlandığınız için bağlantı bilgileriniz loglansa bile şifreli olduğu için çok anlam ifade edetmiyor.
Örnekleri çoğaltabiliriz.
putty ile ssh tünel nasıl yapıyor ?
Nelere ihtiyaçımız var ?
1. İlk olarak, internet’te bulunan SSH sunucumuza erişmemiz gerektiği için, bulunduğunuz ağdan SSH sunucusunun dinlediği port’a erişebiliyor olmalıyız. Bu işlem için müşterideki ağ yöneticisinden yardım isteyebiliriz çünkü genelde internet erşim hiç yoktur veya kullanıcılar HTTP proxy sunucusu üzerinden internet’e erişiyorlardır.
2. putty .
3. SSH modülünün yüklü olduğu ve internetten erişilebilen Unix veya Linux sunucusu.
Putty yi indirmek için arama motorlarına “putty” yazıp çıkan sonuçlardan indirebilirsiniz veyahut bu linkten direk indirebilirsiniz.
Putty’ makinanıza yüklenmez direk çalışan bir programdır.
Internet’teki SSH sunucunuzun dinlediği port “22” olduğunu varsayrak aşağıda anlatıyor olacağım, eğer farklı ise “22” yerine SSH sunucunuzun portunu kullanın
putty‘i çalıştırın.
Host Name or IP addres kısmına SSH sunucusnuzun adresini aşağıdaki gibi yazın.
ve Connection — SSH — Tunnels on Category gidin. Burada Source port ve Dynamic seçeneklerini kullanacağız.
Putty SSH Tunnel üzerinden internet’e eriştirmek için bilgisayarımızda SOCKS sunucusu gibi çalışacağı için dinleyeceği port u Source Port kısmında belirliyoruz ben port olarak “7979” kullandım. Destination kısmını boş bırakıp aşağıdaki seçeneklerden Dynamic i seçiyoruz.
Add’ı tıklayın.
Putty aşağıdaki gibi görünmeli.
Session kımına geri dönüp, Saved Session kısmına vermek istediğiniz session ismini girin ve Save’ i tıklayarak kaydedin.
Putty üzerindeki gerekli ayarlamaları yaptık, şimdi Internet Explorer üzerindekilere sıra geldi.
Internet Explorer’da “Internet Seçenek” ‘lerinden “Bağlantı” tabını seçiyoruz.
Click “Yerel Ağ ayarları” ‘nı tıkılıyoruz .
“Proxy sunucusu kullan … “ kutuçuğunu işaretleyip, Gelişmiş’i tıklıyoruz.
Burada birazda dikkat etmemiz gerekmekte, HTTP / Secure /FTP sunucusu ve“Tüm protokoller için aynu proxy sunucusunu kullan” kutucuklarını temizlememiz gerekmekte çünkü biz SOCKS sunucusu kullancağız. SOCKS sunucusuna’da 127.0.0.1 IP adresi port kısmına da “7979”giriyoruz, Bu port’u putty’i ayarlarken vermiştik, isterseniz farklı kullanabiliriniz. (putty üzerinden de değiştirmeyi unutmayın)
Putty sistemimizde socks server gibi davrandığı için SOCKS server kısmına “127.0.0.1” yazıyoruz.
Şimdi putty penceresinden Open ’a basın
SSH’a login olun ve Internet Explorer ile internet’e bağlanmayı deneyin.
Eğer internet erişimi sağlayamıyorsanız, bağlantınızı koparıp tekrar bağlanın .
How to access internet over SSH tunnel with putty
Posted by cemguneyli in ete on March 1, 2011
Why would we need to access internet with ssh tunnel over putty ? Actually this thread usable for System Admin who is working on customer side. How ? Companies that provide Internet access for their users with restricted access via some url or content filtering software/box. I meant, as a System admin who is need to access lots of web site what is denied by customer url/content filtering software. Also some reason, if you do not want watch your internet access by software. Maybe you need encrypted traffic to trusted internet traffic.
Examples can be increase.
How this stuff will do it.
First at all, we need to access internet (our ssh server) with port 22 (or whatever you are use ssh server port), this will not work, if you had only http proxy server on you network. We must direct access to internet over 1 port for our/public ssh server. So we should request direct access to internet for our ssh server port from network admin. 🙂
What are we need done this ;
1. putty software.
2. Unix or Linux server that support SSH logins.
Just use one of search engine getting putty client. (type “putty download” and click first link 🙂 or click here ).
As you all know putty does not need to install. Just run it.
I assume your SSH server use default SSH port what is port 22, if is not you should use your port on following setting up.
Run putty
Type your ssh server address on Host Name or IP address like following image.
and go Connection — SSH — Tunnels on Category, We will use Source port and Dynamic option to finish our configurations.
Type free port your system like “7979” in Source Port and select Dynamic option. We will use this port for our local SOCKS server what will become putty. Basically, putty provides local Socks server for access to internet through SSH Tunnel.
Then click Add button.
After putty will seem like this.
Then go back to Session category and type a session name in Saved Sessions and click saved button.
And we just finish putty configuration. Now go to proxy setting on your browser, I choose Internet Explorer.
Open Internet Options on Internet Explorer and select Connections Tab.
Click LAN Settings.
Check “Use a proxy server for your LAN….” and click Advanced button in Proxy Server section.
This windows need little attention 🙂 we must clear HTTP / Secure and FTP Server ofc also “Use the same proxy server for all protocols“ and type 127.0.0.1 Socks server section and type 7979 on port (we gave this port on putty, if you want, you can change it on putty also here)
Why we type 127.0.0.1 (localhost) as I said our putty become our socks server on local system.
Now we will just click Open button on putty
type your SSH login information, after succesfully login your ssh server, try to browse on your internet browser.
If is not works just reconnect ssh server.
resource : http://www.emrullahekmekci.com.tr/?p=216
What is mean Burst RAM ?
Posted by cemguneyli in Articles, ete, System, Virtualization on March 1, 2011
What is mean Burst RAM ?
Basicly, You bought 128 MB guarantee RAM and 384 Burst RAM. that’s mean, you had 128 MB RAM all the time. Suddenly your web site or your apps is getting unexpected hit from internet and you need more RAM, at this time you can use your Burst RAM for while if your hosting provider had available RAM your present your VPS as Burst RAM.
resource : http://www.emrullahekmekci.com.tr/?p=203
vm time sync problem with vmware tools 3.5.0
Posted by cemguneyli in ete, Virt-General, Virt-vmware, Virtualization on February 13, 2011
vm time sync problem with vmware tools
“Time synchronization between the virtual machine and the ESX Server operation system.” in Vm Tools, still not sync between vm and ESX server time.
solution: Unchecked — Apply, check again and apply in vm tools