Here's another simple script that will simply write out your AD group memberships to a csv file with the name of a group. Input is a simple text file with one group name per line. This script is adapted from the original at "WiseSoft":http://www.wisesoft.co.uk/scripts/vbscript_list_group_members.aspx.
' VBScript source code
' takes a list of groups in a text file and dumps out a text file with each group's membership.
Set objFSO = CreateObject("Scripting.FileSystemObject")
'change this line to wherever you want to read the input from.
Set objTextFile = objFSO.OpenTextFile("c:\scripts\groups\groups.txt",1)
Do Until objTextFile.AtEndOfStream
groupName = objTextFile.Readline
'Debug.WriteLine groupname
If groupName = "" Then
wscript.quit
End if
groupPath = getgrouppath(groupName)
'Debug.WriteLine groupPath
If groupPath = "" then
wscript.echo "Unable to find the specified group in the domain"
wscript.quit
End if
Set objGroup = getobject(grouppath)
Set objFSO2 = createobject("scripting.filesystemobject")
'change the path to where you want the output files to go.
Set objFile = objFSO2.createtextfile("c:\scripts\groups\" & groupname & ".csv")
q = """"
objFile.WriteLine(q & "sAMAccountName" & q & "," & q & "Surname" & q & "," & q & "FirstName" & q)
For each objMember in objGroup.Members
objFile.WriteLine(q & objmember.samaccountname & q & "," & q & objmember.sn & _
q & "," & q & objmember.givenName & q)
Next
Loop
Set objFile=nothing
'***** Users who's primary group is set to the given group need to be enumerated seperatly.*****
getPrimaryGroupMembers groupName
wscript.echo "Completed"
Function getGroupPath(byval GroupName)
Set cmd=createobject("ADODB.Command")
set cn=createobject("ADODB.Connection")
set rs=createobject("ADODB.Recordset")
cn.open "Provider=ADsDSOObject;"
cmd.commandtext = "SELECT adspath from 'LDAP://" & getnc & _
"' WHERE objectCategory = 'Group' and sAMAccountName = '" & groupname & "'"
cmd.activeconnection = cn
set rs = cmd.execute
if rs.bof <> true and rs.eof<>true then
getgrouppath=rs(0)
else
getgrouppath = ""
end if
cn.close
End function
Function getNC
set objRoot=getobject("LDAP://RootDSE")
getNC=objRoot.get("defaultNamingContext")
End function
Function getPrimaryGroupMembers(byval GroupName)
set cn = createobject("ADODB.Connection")
set cmd = createobject("ADODB.Command")
set rs = createobject("ADODB.Recordset")
cn.open "Provider=ADsDSOObject;"
cmd.activeconnection=cn
'***** Change the Page Size to overcome the 1000 record limitation *****
cmd.properties("page size")=1
cmd.commandtext = "SELECT PrimaryGroupToken FROM 'LDAP://" & getnc & _
"' WHERE sAMAccountName = '" & GroupName & "'"
Set rs = cmd.execute
If rs.eof<>true and rs.bof<>true Then
PrimaryGroupID = rs(0)
Else
Err.Raise 5000, "getPrimaryGroupMembers", "Unable to find PrimaryGroupToken property"
end If
cmd.commandtext = "SELECT samaccountname, sn, givenName, distinguishedName FROM 'LDAP://" & getNC & _
"' WHERE PrimaryGroupID = '" & PrimaryGroupID & "'"
set rs = cmd.execute
while rs.eof<>true and rs.bof<>true
objFile.WriteLine(q & rs("samaccountname") & q & "," & q & rs("sn") & q & _
"," & q & rs("givenName") & q & "," & q & rs("distinguishedName"))
rs.movenext
Wend
cn.close
End Function
Tuesday, March 17, 2009
Wednesday, March 4, 2009
How to dump your web hosting provider in one line.
I used to host with Interland, which is now web.com. They just sent me an email telling me my monthly Windows hosting plan monthly price would double because FrontPage extensions are end-of-life on Linux. Thus I needed to download everything via FTP, because FrontPage will always choke before it completes. Windows GUI FTP clients are no longer free -- and they also choke before finishing 300 MB and thousands of files. (I checked and ChiliSoft ASP isn't supported/sold by Sun anymore, either.)
wget -r ftp://userxxx:password@ftp.mysite.com
Who knew wget could use ftp and be recursive?
wget -r ftp://userxxx:password@ftp.mysite.com
Who knew wget could use ftp and be recursive?
Friday, January 23, 2009
Verizon Rejects My Port Order
After a couple of months, Verizon rejected my port order. I don't really understand why, other the Verizon's internal processes can't handle it, because, well, some number are portable but not others. Below is what Vitelity told me:
Thank you, Verizon.
This order was rejected by the losing carrier. The rejection reason from them is \"The customer had the number converted to a dry loop, it is not portable now. What the customer needed to do was have the DSL transferred to a dry loop and the number converted to a PSTN. Instead, the customer converted the number itself to a dry loop.\"
Thank you, Verizon.
Monday, December 1, 2008
Fun with Peregrine/HP ServiceCenter and USB7 LCD Display
ITIL isn't really fun until you learn the difference between calls, incidents and problems. I have a queue of incidents for which I am responsible, but I can't count on reliable notifications in the form of emails, and the client times me out after about 15 minutes, so I can't see if I have a new incident without logging in again.
I bought the super-cool USB7 7-segment LED kit and soldered it together in about an hour. It's a six-digit display, like you would see on clocks or a calculator. The included driver makes it appear to Windows (or Mac, or Linux) as a serial port. Thus, you write a line to the serial port and it appears on the LCD display. Simple enough.
The trick is getting useful information to the LCD display. How do I get the number of incidents in my queue to the USB7? (A better question might be, how am I supposed to know when there's a new ticket in my queue at all?)
We use Windows at work, so I needed to write this in some kind of dotNet mumbo-jumbo, which is slightly more complicated than PHP, Java ,or VB6, because you need to do things the dotNet way. This uses dotNet 2.0 or 3/3.5 and works in Visual Studio 2005 and Visual Studio 2008 on x86 and x64. It's a simple console application that runs a query and writes it to the com port. Everything is hard coded. Feel free to use it and change it as you wish. Now I need a larger LCD display. SQL query for ServiceCenter 6.1 tables in bold. (the thing with ServiceCenter, at least v6.1, is that incidents are in the probsummary tables. Calls are in the incidents tables.)
I bought the super-cool USB7 7-segment LED kit and soldered it together in about an hour. It's a six-digit display, like you would see on clocks or a calculator. The included driver makes it appear to Windows (or Mac, or Linux) as a serial port. Thus, you write a line to the serial port and it appears on the LCD display. Simple enough.
The trick is getting useful information to the LCD display. How do I get the number of incidents in my queue to the USB7? (A better question might be, how am I supposed to know when there's a new ticket in my queue at all?)
We use Windows at work, so I needed to write this in some kind of dotNet mumbo-jumbo, which is slightly more complicated than PHP, Java ,or VB6, because you need to do things the dotNet way. This uses dotNet 2.0 or 3/3.5 and works in Visual Studio 2005 and Visual Studio 2008 on x86 and x64. It's a simple console application that runs a query and writes it to the com port. Everything is hard coded. Feel free to use it and change it as you wish. Now I need a larger LCD display. SQL query for ServiceCenter 6.1 tables in bold. (the thing with ServiceCenter, at least v6.1, is that incidents are in the probsummary tables. Calls are in the incidents tables.)
'Simple VB.Net 2008/2005 Code to write a single line to the USB7
'available from
'Tested on Win2k3 x86 amd x64 using avrcdc.inf
'11.20.2008 Larry
'release 1.1
'.Net sure is different than good old VB6. Everything's an object.
Imports System
Imports System.Text
Imports System.IO.Ports
Imports System.Data.SqlClient
Module USB7
Dim intTixCount As Int32 = 0
Sub Main()
'this is a standard ServiceCenter 6.1 query to list all the incidents in queue "My Queue"
Dim sql As String = "select count(dbo.probsummarym1.assignment)from dbo.probsummarym1 inner join dbo.probsummarym2 on dbo.probsummarym1.number = dbo.probsummarym2.number and dbo.probsummarym2.close_time is null where probsummarym1.assignment = 'My Queue';"
Using conn As New SqlConnection("Data Source=mydbserver;Initial Catalog=mydatabase;Integrated Security=True")
'you could hard-code a password in that string, but you know better.
Dim cmd As New SqlCommand(sql, conn)
Try
conn.Open()
intTixCount = Convert.ToInt32(cmd.ExecuteScalar())
'ExecuteScalar returns an int -- a regular cmd.execute would result in a recordset
'which would be a problem.
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
conn.Close()
'keep your DBAs happy and close those connections
End Using
Using com1 As IO.Ports.SerialPort = _
My.Computer.Ports.OpenSerialPort("COM2", 9600)
com1.WriteLine(intTixCount)
com1.Close()
'it really is that simple, because we're not reading anything back from the USB7
End Using
End Sub
End Module
Free 411 Service with Asterisk
Google has launched a free 411-style information service. It's not the first free one, by any means, but since it's Google's, I'll have higher expectations about its usability. There's another one available -- that's even older than Google's service. It's too bad you have to pay for e911 service, because doing the same won't send your name and address to your local PSAP.
The catch is, when you're dialing for information, you're at the phone, not the computer, and you may not have memorized the number. (1-800-GOOG-411.) If you're running Asterisk, you can easily reprogram 411 to go to the free 411 service of your choice. Just add the following lines to your extensions_custom.conf in /etc/asterisk:
[from-internal-custom]
exten => 411,1,Answer
exten => 411,2,Dial(SIP/mytrunkname/18004664411|300|)
exten => 411,4,Hangup
The catch is, when you're dialing for information, you're at the phone, not the computer, and you may not have memorized the number. (1-800-GOOG-411.) If you're running Asterisk, you can easily reprogram 411 to go to the free 411 service of your choice. Just add the following lines to your extensions_custom.conf in /etc/asterisk:
[from-internal-custom]
exten => 411,1,Answer
exten => 411,2,Dial(SIP/mytrunkname/18004664411|300|)
exten => 411,4,Hangup
Friday, November 14, 2008
Comments are re-enabled after I identify the spammers' IP addresses
I had 41,000 spam comments in my photo gallery. I had thousands of unpublished spams on my blog here. Spam comments were showing up as valid keywords attracting traffic on Google searches. So a couple of weeks ago, I shut down commenting in MovableType. It turns out that one other problem, mt.cgi consuming 2 G of RAM and all my processor time, was a separate issue. ImageMagick is NOT optional in MT 4.2. I had installed it, but MT couldn't find it. Thus an infinite loop consumed all my resources through our favorite cgi-bin, mt.cgi. Fixed that, but what about comments?
I didn't think Gallery was popular enough to be targeted by automated scripts. I thought CAPTCHAs could stop them. I was quite wrong. I upgrade Gallery to 2.3 and got me a WordPress API key for Akismet, which I'm now using in MT and Gallery.
I also looked at my logs, and found that 99% of my Gallery spam comments came from a limited set of IPs. Since I started blocking them at the firewall, I've seen 13,000 attempted hits from them. Here they are. If you're running Gallery, ban them now.
I didn't think Gallery was popular enough to be targeted by automated scripts. I thought CAPTCHAs could stop them. I was quite wrong. I upgrade Gallery to 2.3 and got me a WordPress API key for Akismet, which I'm now using in MT and Gallery.
I also looked at my logs, and found that 99% of my Gallery spam comments came from a limited set of IPs. Since I started blocking them at the firewall, I've seen 13,000 attempted hits from them. Here they are. If you're running Gallery, ban them now.
91.121.108.25
91.121.110.118
91.121.111.27
91.121.111.28
91.121.120.173
91.121.143.168
91.121.169.207
91.121.179.28
91.121.71.155
91.121.81.48.3
91.121.81.48.5
91.121.84.162
91.121.110.118
91.121.111.27
91.121.111.28
91.121.120.173
91.121.143.168
91.121.169.207
91.121.179.28
91.121.71.155
91.121.81.48.3
91.121.81.48.5
91.121.84.162
Monday, November 10, 2008
Comcast Strikes Back
One week after my port order for my Comcast phone number transferred to Vitelity, Comcast shut down my Internet service. My Comcast voice port line had been dead for a week, and I got home to a dead Internet connection. My Cable modem could pick up an IP but Comcast wouldn't allow it to connect.
I called Comcast customer service and the generally polite customer service rep told me that a port order terminated phone service and Internet service, because it's not possible to activate a Cable modem with voice capabilities with the phone service off. Which is exactly what I had for a week. Customer service rep expressed that Comcast didn't like it when people ported "Comcast's" telephone numbers. Given that Comcast already sued Verizon over the porting telephone numbers difficulty, it's funny.
My only option was to get a new cable modem with no voice ports. After I hooked up the new modem, one call to an also-polite customer service rep got me connected again. I got a new IP, so a quick edit to sip_custom.conf got me connected to Vitelity again.
It was a positive experience, because I feel much freer to switch to whatever ISP I can find that's cheaper. Thus I'm looking at FIOS or DirecTV with a cheap landline for DSL. For those two shows I like to watch on Showtime and HBO, it costs us about $100 a month. Ouch.
What will next month's Comcast bill bring? Credit for terminated phone service? Extra service fees for termination? We'll find out in a month.
I called Comcast customer service and the generally polite customer service rep told me that a port order terminated phone service and Internet service, because it's not possible to activate a Cable modem with voice capabilities with the phone service off. Which is exactly what I had for a week. Customer service rep expressed that Comcast didn't like it when people ported "Comcast's" telephone numbers. Given that Comcast already sued Verizon over the porting telephone numbers difficulty, it's funny.
My only option was to get a new cable modem with no voice ports. After I hooked up the new modem, one call to an also-polite customer service rep got me connected again. I got a new IP, so a quick edit to sip_custom.conf got me connected to Vitelity again.
It was a positive experience, because I feel much freer to switch to whatever ISP I can find that's cheaper. Thus I'm looking at FIOS or DirecTV with a cheap landline for DSL. For those two shows I like to watch on Showtime and HBO, it costs us about $100 a month. Ouch.
What will next month's Comcast bill bring? Credit for terminated phone service? Extra service fees for termination? We'll find out in a month.
Subscribe to:
Posts (Atom)