Wednesday, November 21, 2012
ldifde - an improvement on lpd.exe
Also strange that my last blog is a precursor to this. LDP.exe is a great gui interface for quick ldap queries, but i wanted to automate, script and get output to a file.
Enter ldifde.
with a few switches it allows for simple ldap queries to be scripted and give txt files with results.
You can also determine which attributes you want returned from the AD objects.
Currently using for a monthly review of AD groups.
Wednesday, December 14, 2011
LDP.exe
Typically I need to list members in AD groups and in AD Users & Computers you cannot export the lists.
LDP.exe, once bound to the domain can perform these simple queries and then you can grab the text output :)
I had to change the buffer and page size in the options to be able to get full results for queries that return a lot of text.
Tuesday, October 18, 2011
Folder Polling Script
A neat little script which checks a specified folder (here its C:\Presentations) for the addition of a new file every 5 seconds (WITHIN 5 WHERE) .
Then the script checks for a certain file type, here Powerpoint or web page/link, and then triggers the app accordingly to run this file.
When a new file is detected, the app currently running is closed and a new one started.
I have a server connected to a plasma display, and this script allows users to drag a file into a shared folder, and the server will display the latest file dragged in to the plasma.
(It uses the relevant switches for powerpoint presentation mode - POWERPNT.EXE /S, and Internet Explorer kiosk mode - iexplore.exe -k.)
Set objShell = CreateObject("Wscript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")
'set poll time and location in the next line
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 5 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=""c:\\\\Presentations""'")
Do
Set objLatestEvent = colMonitoredEvents.NextEvent 'waits until next event - next file put into folder.
strNewFile = objLatestEvent.TargetInstance.PartComponent
arrNewFile = Split(strNewFile, "=")
strFileName = arrNewFile(1)
strFileName = Replace(strFileName, "\\", "\")
strFileName = Replace(strFileName, Chr(34), "")
strFileName = Chr(34) & strFileName & Chr(34)
'check for file type and if ppt or htm then close program to allow for new application instance with file
chkPPT
'filter for ppt or iexplore
If Right(strfilename,6) = ".pptx" & Chr(34) Or Right(strfilename,5) = ".ppt" & Chr(34) Then
objShell.Run("POWERPNT.EXE /S " & strFileName)
ElseIf Right(strfilename,6) = ".html" & Chr(34) or Right(strfilename,5) = ".htm" & Chr(34) or Right(strfilename,5) = ".url" & Chr(34) Then
objShell.Run("iexplore.exe -k " & strFileName)
End If
Loop 'keep going
Sub chkPPT
set service = GetObject ("winmgmts:")
bFlag = False
For each Process in Service.InstancesOf ("Win32_Process")
If Process.Name = "POWERPNT.EXE" Or process.name = "iexplore.exe" Then
bFlag = True
End If
Next
'check for file type of newly added file - do nothing if not ppt or ie8
If Not (Right(strFileName,6) = ".pptx" & Chr(34) Or Right(strFileName,5) = ".ppt" _
& Chr(34) Or Right(strFileName,6) = ".html" & Chr(34) OR Right(strFileName,5) = ".htm" & Chr(34) OR Right(strFileName,5) = ".url" & Chr(34)) Then
bFlag = False
End If
'quit applications
If bFlag Then
strWmiq = "select * from Win32_Process where name='POWERPNT.exe'"
Set objQResult = Service.Execquery(strWmiq)
For Each objProcess In objQResult
intRet = objProcess.Terminate(1)
Next
strWmiq = "select * from Win32_Process where name='iexplore.exe'"
Set objQResult = Service.Execquery(strWmiq)
For Each objProcess In objQResult
intRet = objProcess.Terminate(1)
Next
End If
End Sub
Friday, September 30, 2011
When dates are not Excel friendly
I recently had an issue.
I have a report which exports into Excel. The date format from the report is US, and I work in the UK.
Excel tries to recognise the dates as UK, so for dates that fit (eg. month is 1-12) Excel gives me an incorrect date. For dates that don't fit (eg. month is 13-31) then Excel doesnt recognise this as a date and this is formatted as plain text.
An example of this is below:
7/29/2011 7:23:26 AMThese two dates should be 29/07/2011 and 02/08/2011 respectively. However the top one is formatted as text, whereas the bottom one is formatted as date (incorrect format in terms of UK to US!)
08/02/2011 05:45
To rectify this issue I have the formula shown below (which assumes the cell A1 contains the top of the list of exported dates)
=IF(ISNUMBER(A1),DATE(YEAR(A1), DAY(A1), MONTH(A1)),DATE(MID(A1, FIND("/", A1, 4)+1, 4), LEFT(A1, FIND("/", A1)-1), VALUE(MID(A1, FIND("/", A1)+1, 2))))This works exceptionally well.
A user came to me today with the same issue and following giving her this solution, I thought to blog this as being worth sharing.
Saturday, September 24, 2011
XBMC rip audio CD to mp3
- using wireless remote
- all media on mounted USB share (Samba installed so I can access across home network eg configured as a NAS also)
- using the Quartz skin currently
- All music, video, movies, photos cataloged
Thursday, September 1, 2011
Make an iPhone ringtone in iTunes 10
If you’ve made an iPhone ringtone before the process will be familiar to you. This will work the same on both Mac and Windows versions of iTunes 10:
Making the ringtone
• Launch iTunes 10
• Find and select the song you want to make a ringtone out of in iTunes 10
• Then click on the Options tab
• Change the .m4a to .m4r
• Click Yes when you get the next box.
• Drag the file from your desktop back into iTunes
• The file will now be added back into iTunes as a ringtone
• Drag it into your iPhone Ringtones to sync it.
If you cant see the .m4a on the end of the file:
• Open My Computer
• Choose Tools | Folder Options
• Click the View tab
• Untick Hide extensions for known file types
• Click OK
• Now the .m4a should be visible.
Wednesday, June 22, 2011
No MODI in Office 2010! (get it from 2007)
I first tried using the Microsoft Office Customisation tool, by running the command setup.exe /admin (see http://technet.microsoft.com/en-us/library/cc178956.aspx#BKMK_admincmd)
This has an excellent and straightforward GUI, and creates an .msp file which can then be pointed to using the command setup.exe /adminfile test.msp.
However, as my MS Office 2010 is installed and I will be using the license for 2010 to cover the 2007 MODI component (Microsoft's Office licenses are backwards compatible and can be used for the equivalent Office product in an earlier version provided that you are fulfilling the rest of the agreement in regards to number of installations) I did not have a product key for the 2007 install, and the use of the .msp then baulked as this needs to be supplied for the .msp file to go through, even though when I just ran the setup.exe manually it does NOT prompt for a key! (This is due to it seeing the install as an upgrade....
Anyway - I needed another solution, which I found with the setup.exe /config command. (http://technet.microsoft.com/en-us/library/cc178956.aspx#BKMK_config)
This involves copying the default config.xml and modifying it accordingly to your requirements. Below is the .xml I used to specify the MODI component only:
<configuration product="Enterprise">
<display accepteula="yes" completionnotice="yes" level="basic" suppressmodal="no">
<optionstate children="force" id="ACCESSFiles" state="absent">
<optionstate children="force" id="EXCELFiles" state="absent">
<optionstate children="force" id="GrooveFiles" state="absent">
<optionstate children="force" id="OneNoteFiles" state="absent">
<optionstate children="force" id="OUTLOOKFiles" state="absent">
<optionstate children="force" id="PPTFiles" state="absent">
<optionstate children="force" id="PubPrimary" state="absent">
<optionstate children="force" id="RMSFiles" state="absent">
<optionstate children="force" id="VisualStudio_PreviewServer_SPD" state="absent">
<optionstate children="force" id="WORDFiles" state="absent">
<optionstate children="force" id="XDOCSFiles" state="absent">
<optionstate children="force" id="SHAREDFiles" state="absent">
<optionstate children="force" id="TOOLSFiles" state="absent">
<optionstate children="force" id="MSOfficeDocumentImaging" state="Local">
</optionstate></optionstate></optionstate></optionstate></optionstate></optionstate></optionstate></optionstate></optionstate></optionstate></optionstate></optionstate></optionstate></optionstate></display></configuration>
Then I created a batchfile to run the setup.exe /config modi.xml command and hey presto - it works!
For a full list of options that can be configured in the xml I found http://technet.microsoft.com/en-us/library/cc179195.aspx most useful.
Thursday, April 21, 2011
Group Policy <> Registry
Glad I found this link :o)
Saturday, November 20, 2010
Synching
Again I am looking at syncing tools. Windows live beta has now gone and been replaced by Windows Live Sync.
It comes as part of the 2011 Essentials pack, only installable on Windows 7 though, so that makes for a bummer on my main home Win XP laptop. Will still use the web folder for live mesh there. 25 gig of free space is not something to be sniffed at.
This is being written on the blogger tool as part of the live essentials, which at first glance looks pretty cool Im currently on my little d430 ‘work’ laptop, with Windows 7 on it.
Also trying out a few tools to help sync my Google documents, Synchplicity and the office plugin. not installled yet.
WIll update this in a bit, but want to see if the blogger tool works…
Monday, September 27, 2010
Sky+ remote codes
Luckily my dad had a spare new Sky+ HD remote, which I thought would work.
If you need to get a different type of remote to work with Sky, Sky+ or Sky HD. Here's how:
1 press the TV button
2 press and hold the Select and i buttons until the red light on the remote flashes twice
3 press the 1 button (0=Standard, 1=Sky+, 2=Sky HD)
4 press the Select button (the red light should flash twice, if it doesn't, your remote cannot control a Sky+ Digibox)
5 press the Sky button
There are also other 'reset' codes and TV codes, which are easily available on the web. But this was the one we needed to get our remote working with our Sky+.
Now for some soldering of the old remote...
Thursday, September 16, 2010
Restoring a Dell factory image file (.wim) to a new hard disk
Basically, I extracted the factory.wim file from the recovery partition of a failing hard drive, and also got the imagex.exe and it's config files from the tools folder in the recovery partition and stuck them all on my external usb.
Then, using a vista disk, I booted into the recovery options after installing a new hard drive.
Going into command line, I issue the following commands to get the new hard disk ready, active and formatted:
diskpart
select disk 0
clean
create partition primary
assign letter=c:
active
exit
format c: /q /y
once this was complete, I navigated to my USB drive (handy that vista boot disk repair has usb support - as does windows 7) and ran the imagex command to restore the factory.wim file:
Imagex /apply factory.wim 1 c:\
Once this was complete, and again, thanks to the tjb-ts blog, I needed to run the vista startup repair option, which sorted out the booting issue. If I didn't run this option, then vista wouldn't load.
All in all, a successful operation!
Friday, September 3, 2010
Searching in Windows for NOT those things!
After renaming many files with prefixes to allow for faster searching, and getting all the mp3 tags correct and orderly, I wanted to check through my directories for any files that were NOT meant to be in the respective folders. IE in my music directory, for any files that were NOT .mp3, and in my pictures, any files that were NOT .jpg, etc.
I found out you cant do this with Windows search. DOH!
I found out (on Eileen's Lounge - thanks Hans!) that a command line will do this. Yay!
For instance:
dir "C:\Documents and Settings\
will pipe a LOT of info into a text file, detailing any files not of the type .mp3 in the music directory. There is a lot of verbatim with this method to sift through though.
I think Google desktop search could probably do this with less verbatim, but I don't have this app (no major use for it) and didn't want to install it. I would rather write a nice little script...
I called it the NOT search. I have posted it for download with an .exe version on 'Eileen's Lounge (formerly Woodies Lounge)' here.
It basically prompts you for the directory to search on, then for the file types to exclude, ie NOT search on, and then offers folder recursion, ie search through all subfolders. Once complete a nice little report is presented to you in Notepad, detailing any found files and their paths. I found this very helpful indeed and was able to clean up and move any files to where they should be.
The code is below:
'// pmatz's file extension NOT search - sept 01 2010. v 1.1
'// script to search for all files with extension's NOT specified
'//---------------------------------------------------------------
Public strList
main
Sub main
strList = ""
Dim strFileExtensions()
strPath = InputBox ("Enter path to search on." & vbCr & _
"(For root drives please use driveletter" & vbCr & _
"followed by :\ )" ,"pmatz's file extension NOT search")
If IsEmpty(strPath) Then
closeMessage1
Exit Sub
End If
strGetFileExts = InputBox ("Enter filetype/s NOT to search for." & vbCr & _
"(seperate file extensions with commas and leave no spaces" & vbcr & _
"e.g. .mp3,.jpg,.gif,.tar,.iso)","pmatz's file extension NOT search")
bRecurse = (MsgBox("Recurse through all subfolders?",vbYesNo) = vbyes)
strTypes = strGetFileExts
iExtensions= 0
Do
ReDim Preserve strFileExtensions(iExtensions)
iComma = InStr(1,strGetFileExts,",")
If iComma > 0 Then
strFileExtensions(iExtensions) = Left(strGetFileExts,iComma-1)
strGetFileExts = Right(strGetFileExts,Len(strGetFileExts)-iComma)
iExtensions=iExtensions+1
End If
Loop Until iComma = 0
strFileExtensions(iExtensions) = strGetFileExts
search strPath, strFileExtensions, bRecurse
createOutput strPath,strTypes
End Sub
Sub search(searchFolder,excludeTypes,recurse)
On Error Resume Next 'this stops crash for issues with no access etc.
bFound = False
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(searchfolder) Then
closeMessage1
Exit Sub
End If
Set fFolder = fso.GetFolder(searchFolder)
Set fSubfolders = fFolder.SubFolders
Set fFiles = fFolder.Files
For Each fFile in fFiles
For iExtension = 0 To UBound(excludeTypes)
For iStop = Len(fFile.Name)To 0 Step -1
If Mid(fFile.Name,iStop,1) = "." Then
iStop = Len(fFile.Name)-iStop + 1
Exit For
End If
Next
If UCase(Right(fFile.Name,iStop)) = UCase(excludeTypes(iExtension)) Then
bFound = True
End If
Next
If Not bFound Then
strList = strList & vbNewLine & fFile.Path
Else
bFound = False
End If
Next
If recurse Then
For Each fSubfolder In fSubfolders
search fSubfolder.Path,excludeTypes,True
Next
End If
Set FSO = Nothing
Set fFolder = Nothing
Set fSubfolders = Nothing
Set fFiles = Nothing
End Sub
Sub createOutput(strPath,StrTypes)
Set oShell = CreateObject("WScript.Shell")
strOut = oShell.SpecialFolders("Desktop")
Set fso = CreateObject("Scripting.FileSystemObject")
strOut = strOut & "\pmatzFileExtensionNOTsearch_" & getStamp & ".txt"
Set f = fso.CreateTextFile(strOut)
f.WriteLine "pmatzFileExtensionNOTsearch performed on " & Now()
f.WriteLine "Searched through " & strPath & ", excluding types " & strTypes
f.WriteLine "__________________________________________________"
f.WriteLine
f.Write strList
f.Close
oShell.Run("%systemroot%\notepad.exe " & strOut)
Set oShell=Nothing
Set fso = Nothing
Set f = Nothing
End Sub
Function getStamp
strStamp = FormatDateTime(Now(),2)
strStamp = Replace(strStamp,"/","-")
strStamp = strStamp & "_" & FormatDateTime(Now(),4)
strStamp = Replace(strStamp,":","-")
getStamp = strStamp
End function
Sub closeMessage1
MsgBox "Need to enter a legitimate path!",vbinformation,"pmatz's file extension NOT search"
End Sub
Wednesday, August 18, 2010
TreeSize - check your storage capacities
It comes in free version or a paid version with lots more features. But the free version is fine.
This will scan a directory or drive and breakup by folder how much space is used by files and folders.
You can print a 'report' which is helpful, and although the free version doesn't support an export to .csv feature, you can print to XPS for instance and do a little copy and pasting if necessary.
Wednesday, July 14, 2010
Google Sketchup
You gotta play with this, its excellent free software. I am completely immersed in the tutorials and am enjoying every minute.
Have a look and play. http://sketchup.google.com/
Tuesday, July 6, 2010
LDAP query
Function LDAPsearch (strSearch,strQ)
'set variable to hold required amount of attributes
Dim aResults(4)
'set LDAP defaults to root domain
Set rootDSE = GetObject("LDAP://RootDSE")
DomainContainer = rootDSE.Get("defaultNamingContext")
'create recordset connection
Set conn = CreateObject("ADODB.Connection")
conn.Provider = "ADSDSOObject"
conn.Open "ADs Provider"
'set query, using strQ for searched FOR item and strSearch as search ON string
ldapStr = "
'execute LDAP query
Set rs = conn.Execute(ldapStr)
'look for records that meet the query
While Not rs.EOF
'FoundObject is a successful find for query
Set FoundObject = GetObject (rs.Fields(0).Value)
'put results into array with tags
aResults(0) = FoundObject.employeeID
aResults(1) = FoundObject.displayName
aResults(2) = FoundObject.userPrincipalName
aResults(3) = FoundObject.sAMAccountName
aResults(4) = FoundObject.telephoneNumber
'goto next record
rs.MoveNext
'concatenate attributes to string
For i = 0 To 4
strResult = strResult & aResults(i)
Next
'count results (searches may produce multiple results)
iCount = iCount + 1
'add newline results string
strResult = strResult & vbnewline
'continue until no further records are found
Wend
End Function
PureSync
Synctoy didn't allow for easy changes to the directoris and files that you set up for synch.
To cut a long story short there was a clear contender, namely PureSync from Jumping Bytes.
This is a very powerful and flexible tool, with way more options to really specify how you want to back up / sync your files.
I have three main directories that I sync regularly to ensure minimal data loss in the event of a 'catastrophic failure' eg hard drive fail, theft etc. And so I am only scraping the surface in my use of what PureSync can do, even so, it is far more preferable than SyncToy.
If you are looking for a free sync tool that beats the competition, I would recommend PureSync as the solution.
Friday, July 2, 2010
Google Sync - Outlook 2010
Upon an upgrade at work to office 2010 (from XP) the calendar sync no longer worked. A bit of googling and it seemed to be a simple issue caused by the stamp of the 2010 tag on the app, and there were fixes involving hex editing the exe file which is where i thought .... oh no. Then i found this link: (thanks to james manning!)
Google Calendar Sync with Outlook 2010
This is the way to do it. Install the google tool, then use the updated .exe file and it works perfectly again.
Ahh...
Wednesday, February 17, 2010
Media Monkey
I was looking for something better than iTunes as I have LOADS of music and need to keep it organised and searchable, but was finding iTunes both too slow (startup time especially) and creating duplicates and other various niggles. I have to say that within an hour of using (and getting to know its features) MediaMonkey, I am completely converted. And this is the free version. Am seriously thinking of buying the lifetime subscription to the full 'Gold' version. It handles all my music and I have completely un-duplicated my library already. It has EXCELLENT features and in my opinion blows all other players / library managers out of the water.
Friday, October 30, 2009
USB boot, with puppy OS
This is very helpful (and sometimes necessary) for those situations where you need to bypass the main OS on a system:
- System hard drive failure - you need to be try and recover your files
- You just want a quick 'netbook' system with no HDD
- Locked out with no administrator password, and need to reset user accounts etc
- Take an image of a HDD, or indeed write an image
- Unnattended installations
I have recently found a nice simple method to prepare a USB stick for this purpose - making it bootable and using a pretty slick lightweight OS (Puppy Linux) which is in many ways preferable to my usual BartPE windows line of attack. It has most features you need, like basic office apps, network support, browser, USB support, file manager, nice layout and look and feel...
To set up the .iso image (or any .iso for that matter!) on a USB stick and make it bootable, I found a great little application which will do just that. It's called 'UNetbootin' - Universal Netboot Installer.
Simple to use, and works a treat.
Tuesday, September 29, 2009
Windows 7
Suffice to say I have now installed on our main home PC as it needed a reinstall of the OS and I thought why not??? I have to say both me and my wife are impressed with this new OS. There was a little teething trouble getting it installed which was for some reason due to it not being able to discern the system partition when trying to install the OS.
It showed up my 4 hard drives, and correctly showed the basic and dynamic volumes. But it threw an error every time I tried to load it on the system drive. I did a bit of googling with the particular error and found it a fairly common issue, and to do with the system partition not being able to be determined.
The workaround was to temporarily disconnect all other drives (3 SATA and 1 IDE) and then the install went swimmingly, both smooth and fast, much more pleasant experience than the XP install ( which it's got to be said, wan't at all bad in the 1st place!)
Once loaded up, I reconnected my drives and all was fine, Windows 7 detected all the drives and volumes (including my spanned volume from Win XP - my main Doxx volume spanned over 3 drives) although there was a 'missing' entry for a drive, which I think was a ghost of the system volume which obviously was present. I removed this and all was well - perhaps this confusion is from having dynamic volumes and contributed to the install baulking when I 1st tried to write to the system drive prior to the disconnections... anyhow...
Here is my main summary points thus far - nothing majorly technical as yet as this is a home PC, but still points of interest are:
• Speed - refreshingly fast boot up/shutdown times, and general speed of OS is FAST, on a fairly basic spec: 1.8Ghz Athlon 64 2800, 2 Gig DDR 400Mhz RAM, Nvidia GeForce FX5200 gfx.
• Sleep - whilst XP took ages to go into sleep mode, and even longer to come out, and would only come out by pressing the power button on the PC, 7 is again very quick, and comes out of sleep with a touch of the keyboard. That was a nice suprise!
• General look and feel and navigation in Windows 7 is great. No where near a cumbersome or overly protective as Vista, and much smoother operation. The new Aero features are cool and helpful - we have 'Peek', 'Shake', 'Snap' and 'Flip'.
• The system protection features are simple to use, a quick and far less annoying than Vista system prompt for an admin password to change anything that normally doens't need accessing is actually a good feature and easy to use. (This is the 1st PC I am using with a standard account rather than running with an admin account as I did in XP)
• Wallpapers, lovely images, wallpaper cycling, windows transparency, themes, colors... all fresh and new and crisp in Windows 7.
• System Tray - simple, clean and elegant, another improvement - all icons are now monochrome which is a better look and handled better.
• Wireless is much quick to connect and stable. The drivers were loaded automatically, which brings me to...
• Driver support - I did not have to visit any of my hardware's vendor's sites to get drivers for my hardware - all drivers were installed automatically through the install process, and after that whilst temporarily connected to the net via a LAN cable, through windows update - all drivers working well if not better than on XP!
I am sure I will think of further benefits, but this is a start!!! The overall feature set is much more rich than XP - things like parental control built in, Bitlocker encryption, and much more.
Yes, we are liking it.
I will have to update this post in a more technical way with regard to networking / domain / security soon, but I am hopefully and expectant that this new platform is actually a good job done by MS!
Okay, an update - a few weeks on and no system crashes, boot speed still very quick - even with the Kaspersky AV running. Shutdown also very quick as is the sleep function. Still liking it. Might even buy it ;)






