Monday, 19 November 2012

Windows 8 not showing your content in Music, Photos and Videos Apps

I recently upgraded to Windows 8 and have found it strange to get used to, from the Win + I to bring up options for apps to getting used to not having the start menu. However the biggest problem I had was opening the My Music, Photos and Video apps and it not showing ANY of my content. I'd read other users having this issue, but with NAS and other network shares etc but mine is stored on a separate local SATA drive. My Libraries were set to view this information and selecting my Music Library showed all this music that I couldn't use in the My Music app.

There is however a way to fix this! The Music, Photos and Video apps not only use your Libraries to gather media data, it also uses the Windows indexing tool. Now considering my media was on another drive and a while back (for whatever reason I cannot actually re-call) I had disabled the Windows Indexing from looking at my other drives so when I upgraded from Win7 to Win8 this area had never been indexed. So I went into Control Panel>Indexing Options>clicked on Modify and selected these extra folders. I then went into Advanced and kicked off a rebuild to hurry things along and start fresh.

Windows Index locations

After a while of indexing I opened my media Apps in Win8 and the content was all there! Now once you open these applications they begin to then load up previews and thumbnails etc so again once you open the application you must wait a little while (my music took an hour to fully sort itself out) however once its all done everything is there in all its glory. No registry hacks or anything like that, just a slight tweak to what you want indexing. I think I still prefer how Zune works to the new My Music app as I can see much more, however I'm sure it (along with Windows 8) will grow on me. Now time for a beer or a lovely little glass of Glayva to celebrate ;)



Picture Library

Monday, 21 May 2012

Find email address in Public Folders

Looking after several thousand mailboxes, public folders and distribution groups can sometimes make it difficult for you to keep track on where certain email aliases are assigned.

Now mailboxes, distribution groups and mail contacts are easy as you can add a filter in the Exchange Management Console to find these, however the same cannot be applied for Public folders.

Once again PowerShell comes to the rescue in the form of the Exchange Management Shell. Running the following command will bring up all the details you need:

Get-MailPublicFolder email@address.com | Get-PublicFolder
output from Get-MailPublicFolder










This command will bring up the name of the public folder along with the parent path so you know exactly where the public folder lives by showing the folder name and the parent path so you can navigate to the folder in question.

Not only do you get to find the public folder you get to learn a little more about Power Shell with the nice "Tip of the day" that appear in the Exchange Management Shell

Now that deserves a beer!

WinSXS taking up space after Service Pack install

I was working on a users desktop the other day who had an SSD installed a while back (back when 128GB were silly prices!) and it could only hold 64GB and it was full (well around 500kb free). This meant her .ost for Outlook couldn’t expand, causing no end of problems for her. Cleaning out temp files and rebuilding the .ost managed to bring back around 2GB which just wasn’t enough really so after hunting around on the drive to find where the rest of the space had gone I found the WinSXS folder. Now this folder was changed from XP to Vista quite a bit from the old .INF files being in there in XP to .mui, .exe’s in Vista and beyond. This folder allows you to run application such as SFC (System File Checker) or when installing additional features and roles in Server 2008 etc. As handy as this is, it can take up a great deal of space, especially when Service Packs are installed (which was the case for this poor user). To help clean this folder up there is a handy tool built into Windows, which can be run from the command prompt (you need to run the command prompt in Elevated Mode to run. To do this, hold down shift and right click on the command prompt icon and select Run as administrator…) which does a nice job of doing it all for you. Please bear in mind after this runs, you won’t be able to roll-back from the Service Packs. The command to run is below:


DISM /online /Cleanup-Image /SpSuperseded
This will take around 20-30minutes to run (depending on the OS and how much space it can reclaim) and can usually bring back around 3-5GB, which is the perfect amount of time to crack open a can of beer ;)
WinSXS size before command was run

WinSXS size after command was run

Saturday, 11 February 2012

Save As PDF not working in Microsoft Office products

Recently I had two issues to sort out in the office. The first was a few users from a group company that were having issues with some powerpoint files that used a truetype font. Powerpoint would get halfway and then crash every singletime. The second issue was in all Microsoft Office products where users would go to create a PDF by using the Save As... feature instead of using the print to option and using cutePDF or the Adobe PDF printers.

Both these faults started happening around the same time (Mid November) but I treated these as seperate issues to start as they came from different companies. I could replicate both errors on my PC and I didn't have any pdf printers installed so it wasn't an issues with either of those products. I decided it might be a Microsoft Office patch and went through each one and still no fix in sight.

I did one last check with another desktop of mine that hadn't had Novembers patches installed and this had no problem at all with either of the reported faults. This gave me somewhere to look, which was in the set of patches released in November and I found the error. MS11-087 was released to fix a zero day fault in Windows that takes advantage of an exploit in the font subsystem (the worm is named Duqu so if you are a creative using TrueType fonts from any site known to Google be careful and make sure your Windows PC is running AV.) What this patch does is change the file permission for a file called t2embed.dll which lives in Windows\system32 (it also lives in the sysWOW64 folder for 64bit systems.)

and for those wanting to know how to how the Duqu worm works:
Druqu worm cover by MS11-087 patch

So to fix this issue you simply have to undo this permission change and give users read access to this file(s if you're on a 64bit system) and the change will kick in straight away. Either that or you can down this .msi from Microsoft that does the exact same thing, just remember to run the command prompt as an administrator and run msiexec to undo the changes, and then relax and have a beer...

Monday, 20 June 2011

SQL Server not starting after an update

So this morning after the patch weekend following Microsofts Patch Tuesday I updated our SQL 2008 R2 server with a security patch (KB2494088) and rebooting the MSSQL Server service refused to work. It would start up but when trying to login all you got in the SSMS(SQL Studio Management Studio) was "login failed for user. Reason: Server is in script upgrade mode. Only administrator can connect at this time"

Upgrade script

And after 2 minutes the SQL service would stop. And you're back to square 1. In the event log all i was seeing was the following two errors:

Script level upgrade for database 'master' failed because upgrade step 'sqlagent100_msdb_upgrade.sql' encountered error 598, state 1, severity 25. This is a serious error condition which might interfere with regular operation and the database will be taken offline. If the error happened during upgrade of the 'master' database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate corrective actions and re-start the database so that the script upgrade steps run to completion."
and


Cannot recover the master database. SQL Server is unable to run. Restore master from a full backup, repair it, or rebuild it. For more information about how to rebuild the master database, see SQL Server Books Online.

This is where i sh*t myself! After a quick trip i composed myself and decided to try a rebuild of the database. In SQL 2005 and SQL 2008 R2 i know its different that SQL 2000. To do a rebuild in SQL Server 2008 R2 i used the installation media ( you can use the local setup file which lives in C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2) and used the setup.exe file and ran the following command:

SETUP.EXE /ACTION=REBUILDDATABASE /INSTANCENAME=mssqlserver /SQLSYSADMINACCOUNTS="DOMAIN\administrator" "NT AUTHORITY\SYSTEM" "NT SERVICE\MSSQLSERVER" /SAPWD=sapassword
This ran successfuly (it didnt come up errors once it has run) but alas the same problem, so rebuilding the master database didnt work.

What did work for me was stopping the MSSQL service and starting it up again by using the below commands:

>cd "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn\"
>sqlservr.exe -c -m -s SQLinstance
>sqlcmd -S SERVERNAME,1433 -E
 
Now the switches on sqlserver allow it run not as a service (-c) and in single user mode (-m) and the -s allows you to specifiy the server name. Running SQL in single user mode means no-one can login normally and allows SQL to get on with its upgrade script in peace.

I left this to run for around 15 minutes (if its a busy SQL server you'll see many attempts of other servers/workstations logging in. To stop this i just pulled the network plug as I was working locally. If you need to remote on don't do tis...for obvious reasons :p) and after this finished and I can could see the upgrade script ran successfully I was able to start the SQL service up in the Services.msc and login OK using the SSMS. No need to re-run the patch or roll back and get screamed at by any developers (which could of been the case for me)

After this fault happened I now always allow SQL to start in single user mode after an update/upgrade so it can run these scripts peacefully. Its not really needed and its mainly me siding on the side of caution but it never hurts :)

Friday, 30 July 2010

Create a mac admin via Terminal and turn VNC on

Now a while back we replaced our LANDesk solution with a new appliance at the time called KBOX (made by KACE who are now owned by Dell) and the major benefit to us was the support for Macs. LANDesk though officially supported Apple Macs, was quite weak and we couldn't rely on it. Shame really as LANDesk for PCs was fantastic in my eyes!

Now the problem came a week before. Basically because of various acquisitions and no set standard for the local admin account on Macs, doing a mass roll-out of the new KBOX Agent to 200odd Macs was going to be quite a challenge. So I created a little script (works in Leopard and Tiger but I cannot confirm for Panther or Jaguar ) and packaged it using Package Maker on my Mac (This is part of the developer add-ins that come on the OS X discs)

#!/bin/bash

sudo /usr/bin/dscl . -create /Users/macadmin

sudo /usr/bin/dscl . -create /Users/macadmin UserShell /bin/bash
sudo /usr/bin/dscl . -create /Users/macadmin RealName "macadmin"

sudo /usr/bin/dscl . -create /Users/macadmin UniqueID 550

sudo /usr/bin/dscl . -create /Users/macadmin PrimaryGroupID 20

sudo /usr/bin/dscl . -create /users/macadmin NFSHomeDirectory /Users/macadmin

sudo /usr/bin/dscl . -passwd /Users/macadmin password

sudo /usr/bin/dscl . -append /Groups/admin GroupMembership macadmin

sudo /usr/bin/dscl . -create /Users/macadmin picture "/Library/User Pictures/Sports/8ball.tif"

Now this creates a Mac admin account called....well macadmin! Now I'll walk through what exactly this script does so you're more aware and can customise to your own liking. I have labelled items you can customise for yourself in red.

"sudo /usr/bin/dscl . -create /Users/macadmin" will create a user with the short name for you called macadmin (If you are used to UNIX then you'll know it is limited to 8characters but Macs doesnt care and let you put in whatever you want but for best practise stick to 8characters or below).

"sudo /usr/bin/dscl . -create /Users/macadmin UserShell /bin/bash" Tells OS X that whenever Terminal is used by the user its default shell will be /bin/bash. which is the default for Mac users so it would be best to leave this as it is.

"sudo /usr/bin/dscl . -create /Users/macadmin RealName "macadmin"" Makes the actual login name macadmin (you can also login as the short name too. So for me my short  name is mightymd (because my name is longer than 8characters its simply mighty and then my initials) and my RealName is Mike Donaldson.)

"sudo /usr/bin/dscl . -create /Users/macadmin UniqueID 550" and "sudo /usr/bin/dscl . -create /Users/macadmin PrimaryGroupID 20basically give the account a UniqueID (this is required and starts from 501 for the first account and then 502 for the second account....so I have chosen 550  because its doubtful you will have 49 other local accounts on your macs!) and the PrimaryGroupID is set to 20 by default so I have left that as is.

"sudo /usr/bin/dscl . -create /users/macadmin NFSHomeDirectory /Users/macadmin" creates and sets the users profile to be saved in /Users/macadmin. Obviously if you call your user something else then it would be /Users/username.

"sudo /usr/bin/dscl . -passwd /Users/macadmin passwordThis will set the macadmin accounts password to password. So you can put in whatever you like for this. But you need to keep this script safe as the password is sitting there in clear text and is risky if everyone can access it.

"sudo /usr/bin/dscl . -append /Groups/admin GroupMembership macadminThis adds the macadmin user to the admin GroupMembership.

"sudo /usr/bin/dscl . -create /Users/macadmin picture "/Library/User Pictures/Sports/8ball.tif"" This is basically just to give the account a specific login pic. I use the 8ball but you can pick whatever you like. Just take a look in "/Library/User Pictures" and choose your favourite and add it in.

8ball

Now you can run that via ARD or save this as a .sh file by using Text or Xcode (i prefer using Xcode just so I can verify my scripts) and then package it using Package Maker and you have your own .pkg file to deploy out whenever you are at the macs in question and bingo!

The next problem I came against was turning on VNC support on the Macs and setting a password for it. Below does this easily enough. It basically turns on VNC, give all local users full access, restarts the agent so the changes are in place and you can specify a password so that when you connect via UltraVNC/RealVNC or any other VNC product it will ask for a password first, so that no-one can just hop on to anyone elses mac without authorisation

#!/bin/sh

/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -allowAccessFor -allUsers -privs -all -restart -agent -menu -clientopts -setvnclegacy -vnclegacy yes -setvncpw -vncpw "password"

And then once you've got it all working......have a beer!

Thursday, 29 July 2010

Create new mail contacts from a CSV file for Exchange 2007/2010

Today I had a colleague come to me, asking for help as she had a user asking to have 649 mail contacts created and added to a distribution group by the end of the day.

Now instead of sitting there and slowly adding in each and every single contact individually (which if you've had to do this before in Exchange you'll know it's an absolute nightmare!!) I decided to modify a script I wrote a while back for importing mailboxes from a CSV file.

So the format of the CSV file should be:

NameEmailOUPAth
Test Usertest.user@domain.comdomain.local/Mail Contacts/Test

For the OUPath you can easily find this out by going into your Active Directory and right clicking on the folder you wish the mail contacts to be imported into, and going to Properties
OU Properties

As you can see in the Object section you can find out the OU Path, by looking at the Canonical name of object:

Once the .CSV file is created and formatted correctly you can use this wonderful little powershell script I wrote:


Import-CSV C:\createnewcontact.csv | ForEach-Object{
New-MailContact -ExternalEmailAddress $_.Email -Name $_.Name -OrganizationalUnit $_.OUpath
}


Now I'll talk you through section by section on what this script does so you're a little more aware (and i can prove I didn't just copy and paste from a website :p)

Now "Import-CSV C:\createnewcontact.csv" basically tells Powershell to import data from the CSV file which lives directly on the C:\ and is called createnewcontact.csv (bare in mind if you call your CSV differently you will need to change this section)

"ForEach-Object"{ allows you to perform an action on each item in the collection (in this case everything between the { }

"New-MailContact" This is kind of self-explainatory to be honest. If you want a new mailbox you put in New-Mailbox and for a new mail contact you use New-MailContact


Now when you run New-MailContact manually into PowerShell it asks you for 2 pieces of information:

  • ExternalEmailAddress

  • Name

So when your PowerShell script runs New-MailContact it still needs this information. So by using "-ExternalEmailAddress$_.Email" you are telling the script that when it gets asks what the -ExternalEmailAddress is the PowerShell sees $_.Email which signifies to it that it should get this information from the Email column ($_. tells it to use the column and the name after it is the column name)

This is the same for -Name $_.Name -OrganizationalUnit $_.OUpath

I'm not the greatest at explaining things so I do apologise. If in doubt just copy exactly what I've done and you'll be fine :)

Mailcontact Powershell

Pop in the location of the script into Power Shell (or if you're really lazy just drag and drop the script from Explorer into the Power Shell window) and hit enter and watch it run away and create hundreds of mail contacts from your .CSV file in seconds...and then have a beer