March 2009 Entries

Windows Live & facebook

imageI was watching a couple of videos this lunch time that were on the BBC website about Windows 7 and one other them was highlighting the new Windows Live Essentials.

 imageThe Windows Live Essentials contains Windows Messenger, Windows Mail and the Live Photo Gallery. What they also announced what that Windows Live had partnered with facebook so that your statuses and photos on facebook could then be shared with your contacts within your MSN network. I have yet to try this out fully but it let me sign in to facebook from within Live Messenger and gave me all the facebook feeds like you get on the facebook App on the iPod Touch and iPhone.

The other thing that they mentioned was that Dell Will be shipping shipping their PC’s with Windows 7 (once it has been released) with the Live Essentials preinstalled along with live search, I am not too sure how well this will go down as I know from my Visit to Dell’s EMF last year customers were complaining about Google desktop being installed as part of their standard build.

For a home build I cannot see the issue to be honest, if they didn’t put them you will more than likely put them on at some point.

For large business that buy bulk from dell will do one of two things: Go through the Custom Factory Image Process (CFI), Where you provide Dell with a copy of your standard build image and every PC your order from Dell comes with that image, or you more than likely will just re-clone and put your image on once you get the PC delivered.

My only question just now is how will that work as I use my kemponline.co.uk email for most things and have a hotmail.co.uk address purely for windows live…

Well lets see how it works shall we!

Tripple Sceens

For the last couple of years I have been using dual screens, it makes life so much easier, and I did find myself being more productive. I was running Windows Vista at the time and I did have a 2nd Video card but Vista being vista did not like having two different cards in the same PC. So whilst I was running with Vista I was using the ATI Radeon x300 card with dual screens.

Well I eventually had enough with Vista and went back to XP as I found myself having to re-boot once maybe twice a day. I started off liking Vista, with all its bells and whistles, but underneath its pretty interface it was a pretty shocking unstable OS.

So once I had installed XP on I thought I would give the third screen ago using the 2nd Graphics card I had. So I now had a PCIe Graphics card and a PCI Graphics card in my PC both of which are dual heads. So potentially I could put 4 monitors on :).

So I booted up my PC and the PCI card was detected as the primary card, loaded up Windows and then installed the drivers.

I went in to Desktop Properties and selected settings and I was given the option for 4 monitors:

image

after playing around a bit and setting the middle (widescreen) monitor as my primary display I had my 3 screens up and running. I did try plugging in a 4th monitor but  I think the 2nd head on the PCI graphics card is faulty as I got  a blank screen, oh well I am sure that 3 monitors is enough!

I then installed display fusion again, this would enable me to set a different image for each monitor

image

so with a messy desk this is what the final out come is:

image

So to be honest I don’t think that I can fit a 4th monitor on there anyway I could just maxivista to extend on to my laptop’s monitor!

iPod Touch, iTunes and Windows 7

I have been running my laptop with Windows 7 now since its release in January, and I have to say I have had little problem with it less problems that I had with Windows Vista! it is far more stable than Vista and for a beta that is saying something.

there are several features that I really like about it, however the one gripe that I have at the moment is that when it comes to syncing my iPod Touch with photos iTunes seems to hang. I am not too sure why but I am guessing it has something to do with the new imaging software bundled with Windows 7.

Other than that it all seems to be working ok. :)

User home drives map to the root of the share instead of their own folders

I have seen this on more than a handful of pc’s on the network where you have a users home drive (H: for example) is pointing to \\server\share\%username% but or some reason H:\ is pointing to \\server\share.

Well the good news is that there is a simple fix to this one! there is a setting in the local policy of the computer, which can be set through GPO.

image

All you need to do is enable the Wait for the network at computer startup and logon setting in: Computer Configuration\Administrative Templates\System\Logon\

If you are doing this for an individual computer you can do it through the Group Policy editor adding into an MMC, other wise if it is for the entire domain then you can do it through GPMC (Group Policy Management Console).

All your users Home drives will name be mapped to their folder and not the root of the share.

The problem is due to the user logging on to the computer immediately once he or she has turned it on and the network services haven’t fully started (I think). this setting does however add a few seconds on to your start up time, which some users might actually find is a life time for them as they want there PC logged on there and then :)

Retrieve Disk info from servers set by a specific threshold

Whilst I am in the process of writing these scripts to make my job easier I learnt that there is such a thing as information overload!

The disk space report is  all very well but, what if you only wanted to see the servers with disk running low on space, we set our thresholds typically at 20% as that should give us enough time to plan new disks if needed or address the problem for most servers.

So I started with a script that checked all the disks attached to servers listed in the text file and only reported back if they were under 20%. initially I had a problem when I used the < 20 command it still reported back with everything! what i needed to do was actually set it to < .2.

So I now had this script that would go away and check all the servers and report back to a test.txt file.

If I automate this to run every day and  I want it to report to a share on the network and the file names are all the same then I will only have the one file as it would get over written every day, so the 2nd revision of the script contained the date function so it would be a unique filename for that specific date.

I then thought, what if you didn’t like the name test.txt, its not a very good name for the output file so I decided to set it so that you only have to change the name and path once in the script rather than every place it is referenced to further down.

I also set a completed message in there so it would tell you that it had completed, would give you the file path and then ask if you would like to open the file or not. if you say yes to opening the file it will launch Excel and open in there as the file is a Tab delimited text file.

The next revision of the script I set the percentage up with the file name so the output file would contain it too. to get the free percent I just divided that number by 100.

percentage = 20
repfilename = "DiskSpaceLessThan"
repdate =  "-" & (GetDate (Now, ""))
reppath = "C:\output\"
repext = ".txt"
FreePercent = percentage / 100
myfile = reppath & repfilename & percentage & repdate & repext

So if you wanted to change the percentage all you would need to do would be to change it where funnily enough it says percentage = 20!

I thought that if you run this script manually (by dragging the list of servers onto the VBScript file) you may want to specify the threshold, so I change the percent = 20 line to an input box.:

percentage=InputBox("Please enter the threshold eg 20 for 20%:")
repfilename = "DiskSpaceLessThan"
repdate =  "-" & (GetDate (Now, ""))
reppath = "C:\output\"
repext = ".txt"
FreePercent = percentage / 100
myfile = reppath & repfilename & percentage & repdate & repext

I thought as I was on a roll this morning with the scripting I will create a basic script that will check the space for a specified server and report to the text file and open up. I get asked on a regular basis on how our exchange server is doing for free space, so this will save me either logging onto the server to check, and or looking through log files that had been sent that morning. The script would give me the free space at that point in time.

I have put the three scripts into a zip file for download:

 

Download Now.

Get serial numbers from multiple servers

So, since I was playing around with scripting I thought that I would try and get the serial numbers of all my servers on the network. so I used the basics of the script I wrote for the disk space and adapted it to get the BIOS info of the server.

Again it uses the idea of dragging a list of servers in a text file

Here is the script:

dim filesys, text, readfile, contents

'Create a Shell and FileSystem Object
Set WshShell = WScript.CreateObject("WScript.Shell")
set filesys = CreateObject("Scripting.FileSystemObject")
'Set text = filesys.CreateTextFile("c:\serial_nos.htm")
'Read the Argument, pathname of file dropped onto script
Set objArgs = WScript.Arguments

For I = 0 to objArgs.Count - 1

     filname = objArgs(I)

'Open the file
set readfile = filesys.OpenTextFile(filname, 1, false)

'Get a line from the input file, ignore a semi-colon
do while readfile.AtEndOfStream = False
     Name = readfile.ReadLine
     Getchar = instr(Name,";")

     ' For Debugging wscript.echo Getchar
     if Getchar = "0" then ShowDriveInfo(Name)

loop

readfile.close

Next

Sub ShowDriveInfo(SrvName)
Dim strComputer, objWMIService, colItems, objItem
Dim fso

Set fso = CreateObject("Scripting.FileSystemObject")
Set writefile = fso.OpenTextFile("c:\serial_nos.txt",8, True)

strComputer = SrvName
on error resume next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_BIOS",,48)
For Each objItem In colItems
writefile.Writeline  (strComputer & "    "  & objItem.SerialNumber)
Next
End Sub

Next plan is to adapt it to get OS and service pack level etc….

Check the diskspace on all your servers in one go

A few years ago I decided to write a script to automate this process for me as at that point in time I was managing about 30 servers each with 3 maybe 4 drives.

The script I had back then was pretty neat and reported all the disk space statuses of servers listed in a text file, just by dragging a text file with the servers listed in it onto the VBScript.

The problem with the original script was that it checked each server for drives C: to L: so I had a piece of code for each drive like this:

'C$ share  Set drv = fso.GetDrive(fso.GetDriveName("\\" + SrvName + "\C$_
"
))

writefile.Write (tblstart2)
writefile.writeline (tcspace1 & SrvName & fin) & _
(tcspace2 & "C:\" & fin)& _
(tcspace3 & drv.volumename & fin) & _
(tcspace4 & FormatNumber(drv.TotalSize / 1073741824,_
2)& "GB" & fin) & _
(tcspace5 & FormatNumber((drv.TotalSize / 1073741824)_
-(drv.FreeSpace / 1073741824), 2) & "GB" & fin) & _
(tcspace6 & FormatNumber((drv.FreeSpace / 1073741824)_
, 2) & "GB" & fin) & _
(endtr)
writefile.writeline (tblend)

'writefile.write SrvName + " " + vbTab + "C$" + vbTab + _
drv.filesystem + _
'vbTab + vbTab + FormatNumber(drv.TotalSize / 1024, 0)+ " _
Kb" + vbTAb + _
'FormatNumber((drv.TotalSize / 1073741824)-(drv.FreeSpace /_
1073741824), 2) + " GB" + vbTab + FormatNumber(drv.FreeSpace _
/ 1024, 0) +_
'" GB" + vbCrlf totCap = totCap + (drv.TotalSize / 1073741824) totUsed = totUsed + (drv.TotalSize / 1073741824)-(drv._
FreeSpace / 1073741824)
totFree = totFree + drv.FreeSpace / 1073741824
Set drv = Nothing
 

so I had that from C$ to L$

The new script was a lot simpler:

 

strComputer = SrvName

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &_
"\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where DriveType = 3")
For Each objDisk in colDisks
intFreeSpace = objDisk.FreeSpace
intTotalSpace = objDisk.Size
'Wscript.Echo strComputer, objDisk.DeviceID,_
objDisk.FreeSpace
pctFreeSpace = intFreeSpace / intTotalSpace usedSpace = intTotalSpace - intFreeSpace GigFree = FormatNumber (intFreeSpace / 1073741824, 2) Gigtot = FormatNumber (intTotalSpace / 1073741824, 2) totUsedSpace = FormatNumber (usedSpace / 1073741824, 2) writefile.Writeline (strComputer & " " _
& objDisk.DeviceID & " " & Gigtot & " " & _
totUsedSpace & " " & GigFree & " " & _
FormatPercent(pctFreeSpace))

Next

That is the main part of the script that checks all the disks on all the servers on a text file.

The complete script is at the bottom on the post. I have just done a simple copy and paste from Notepad++ as the code snippet plug-in for live writer doesn’t like the width of the blog skin at the moment :)

All I need to do now is create a text file with all my servers in it (each server on a new line) and then drag that file over the VBS file and it will run all those servers against the list.

Looking at all the possibilities I cold potentially get more information out of the servers I run it against so watch this space!

The first revision of the script outputted to a text file called Disk Report.csv. however I hadn’t accounted for the TB disks I had in a couple of the servers so the comma separated txt file proved to be problematic as it would spit up 1,024 GB into two columns.

So I ended up using a tab separated txt file.

The next thing was to save the file with the date in the file name so I could save more than one file!

VBScripting has limited date formats so I needed a custom function that would set the date format to ISO (YYYYMMDD)

I found a function already created on the link below.

 

----------Final Script Below here---------------------

 

'VBScript to check the disk space on a text file containing a list of servers
'created by Andrew Kemp on 12th March 2009
'Date Function by: http://aspadvice.com/blogs/xsherry/archive/2005/01/27/2166.aspx
'Revision 6

dim filesys, text, readfile, contents, datenow
Function GetDate(dateVal, delimiter)

    'To comply with Option Explict
    Dim dateMonth, dateDay
    dateVal = CDate(dateVal)
        ' Converts the dateVal parameter to a date.
        ' This will cause an error and cause the function
        ' to exit if the value passed is not a real date.
    delimiter = CStr(delimiter)
        ' Converts the delimiter parameter, which designates
        ' the delimiting character between the datepart values
        ' to a string value.  If you don't want a delimiting
        ' character, (such as / or -) then you'd simply pass
        ' in an empty string for this parameter.
    dateMonth = Month(dateVal)
     dateDay   = Day(dateVal)
    GetDate = CStr(Year(dateVal)) & delimiter
    If dateMonth < 10 Then
        GetDate = GetDate & "0"
    End If
    GetDate = GetDate & CStr(dateMonth) & delimiter

    If dateDay < 10 Then
        GetDate = GetDate & "0"
    End If
    GetDate = GetDate & CStr(dateDay)
End Function

' set datenow = GetDate (Now, "")

'Create a Shell and FileSystem Object
Set WshShell = WScript.CreateObject("WScript.Shell")
set filesys = CreateObject("Scripting.FileSystemObject")
Set text = filesys.CreateTextFile("c:\Disk Report-" & GetDate (Now, "") & ".txt")

text.Writeline ("Server Name    Drive    Total Disk Space (GB)    Used Space (GB)    Free Space (GB)    Free Space (%)")
text.close

'Read the Argument, pathname of file dropped onto script
Set objArgs = WScript.Arguments

For I = 0 to objArgs.Count - 1

     filname = objArgs(I)

'Open the file
set readfile = filesys.OpenTextFile(filname, 1, false)

'Get a line from the input file, ignore a semi-colon
do while readfile.AtEndOfStream = False
     Name = readfile.ReadLine
     Getchar = instr(Name,";")

     if Getchar = "0" then ShowDriveInfo(Name)

loop

readfile.close

Next

Sub ShowDriveInfo(SrvName)

Dim fso

Set fso = CreateObject("Scripting.FileSystemObject")
Set writefile = fso.OpenTextFile("c:\Disk Report.txt",8, True)

strComputer = SrvName

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk Where DriveType = 3")
For Each objDisk in colDisks
    intFreeSpace = objDisk.FreeSpace
    intTotalSpace = objDisk.Size
    'Wscript.Echo strComputer, objDisk.DeviceID, objDisk.FreeSpace
    pctFreeSpace = intFreeSpace / intTotalSpace
    usedSpace = intTotalSpace - intFreeSpace
    GigFree = FormatNumber (intFreeSpace / 1073741824, 2)
    Gigtot = FormatNumber (intTotalSpace / 1073741824, 2)
    totUsedSpace = FormatNumber (usedSpace / 1073741824, 2)
   writefile.Writeline  (strComputer & "    " & objDisk.DeviceID & "    " & Gigtot & "    " & totUsedSpace & "    " & GigFree & "    " & FormatPercent(pctFreeSpace))

Next

writefile.write vbcrlf + vbcrlf

writefile.close

End Sub

Office Live Add-in 1.3

I recently re-installed my PC went back to XP Pro as Vista was just too unstable for my liking and ran a windows update on it.

On the optional updates there was an update for Office Live Add-in, so I thought why not install this!

After installed I re-booted and all looked ok. I was happily browsing the web with no problems, I then needed to go to our Intranet for something (running on Sharepoint) and I was prompted for a username and password. I entered in my credentials (both Admin user and regular user) and could not login, I hit cancel and it logged me in fine!

after process of elimination it turned out to be this live add-in. I had previously thought that it was caused by the hotmail connector for outlook! A  simple uninstall of the Office Live add-in seemed to fix the problem :)