Removing dead library servers and hosts from SCVMM
by caveman_dick on Nov.15, 2011, under Problems Solved, SqlServer
A while back I was setting up TFS Lab management so that we can start automating a lot of our integration testing. In the process of testing the deployment of the servers and the auto configuration scripts I was creating a lot of temporary virtual servers on the domain and using up IP’s on the network before they could be released. Therefore I wasn’t too popular with the OP’s guys and they decided to put the lab server in it’s own domain.
Unfortunately this caused a few issues as it meant that the SCVMM backed could not contact the hosts and the library servers as they had moved domain. Removing the hosts was a simple matter of dropping to PowerShell (There is a handy button at the top of the SCVMM Admin console) and running the following command:
However the PowerShell command for removing dead library servers is not so helpful as it doesn’t have a “Force” flag and it comes up with an error saying it can’t be contacted:
Luckily as the SCVMM backend is controlled by Sql server it wasn’t too difficult to find where the definitions of the library server were stored. Just connect to the SCVMM database instance ([YOUR_SCVMM_SERVER]\MICROSOFT$VMM$) and the table you need to look at is the tbl_ADHC_Library table. Firstly do a select on the table to get the GUID/UNIQUEIDENTIFIER of the library server(s) you need to delete:
go
select
LibraryID,
ComputerName
from dbo.tbl_ADHC_Library
From this query take the LibraryID field and for each of the library servers you need removing, run the following command:
go
exec prc_ADHC_Library_Delete '[LibraryID]'
Hey presto all the dead servers are now gone!
As always please make sure you have a backup and don’t blame me if you break your SCVMM server!!
Coding Badger Sponsorship plug!
by caveman_dick on Jul.27, 2011, under Uncategorized
Thanks to Barry O’connor for sponsoring me on my charity challenge!
Take a gander at his blog which can be found here and you may learn a thing or two! I certainly did, apparently Barry has so much spare time he can answer lots of questions on StackOverflow! Oh to be a contractor!!
Sponsor me and get a “free” plug to your website on my blog!
by caveman_dick on Jul.27, 2011, under Uncategorized
Thanks to SharpCrafters (the makers of PostSharp THE AOP framework for .Net
) sponsoring me on my Princes Trust charity challenge I have had the great idea of giving away free plugs to your site and/or product if you sponsor me.
Any amount will get a thank-you blog post but if you sponsor me £100 or more you will be able guide the content of the blog-post (within reason!
). If you have donated over £100 DM me (@caveman_dick) and I will send you details of how to contact me!
As SharpCrafters were the first they even get a banner!
Specifying a different source directory in OpenWrap
by caveman_dick on Jul.20, 2011, under Tips and Hints
Currently our source tree is very similar to the recommended OpenWrap layout other than one difference, the “src” dir is called “Source”. This only causes an issue when it comes to building the wrap itself as by default the command tries to find any projects in the src folder. It’s a simple config change to get this to work, just add the following line to your .wrapdesc file:
Thanks to SerialSeb for an awesome package manager and super-quick support via twitter!
Please sponosor me on my charity challenge!
by caveman_dick on Jul.20, 2011, under Uncategorized
This year at the end of September I am embarking on a charity challenge for the Princes Trust. This has been partially organised through my new employers (Advanced Health and Care Ltd part of the Advanced Computer Software Group) and they will be kindly sponsoring me to the tune of £100 but I need to raise the rest.
The challenge I’m entering is the Wild UK challenge which involves racing from the north coast to the south coast of Devon by cycling, hiking and kayaking a total of 100 miles!
So far I have managed to raise a bit at work by doing selling some cakes I have baked and will be doing a lottery next payday. I did plan to sort out a load of my junk to sell at a boot fair however this has been quite difficult to find the time (I moved out of London in Jan as my mum health was deteriorating and she has recently been diagnosed with Alzheimer’s
).
Unfortunately I’m still majorly short of the £800 target (£600 of which I need to raise by the end of August!), so hopefully this is where you will be able to help!
My sponsorship page can be found here. Anything that you can spare would be very much appreciated. Just think if you don’t have that extra drink down the pub on Friday, you can easily spare a fiver!
Thanks everyone!
Resharper Tip: Generating guids
by caveman_dick on May.12, 2011, under Tips and Hints
Need to insert a guid into your code? ReSharper can help with this, just type “nguid” and press tab, hey-presto a new guid is generated and shown in different formats in the intellisense dropdown:


Enabling a project to have multiple StyleCop targets.
by caveman_dick on Apr.27, 2011, under Tips and Hints
As the RC is now out for StyleCop 4.5 I wanted to give it a go mainly to see if the ReSharper integration included works with Resharper 6 (unfortunately it doesn’t
). Unfortunately it includes a breaking-change if you import the StyleCop.targets file (so that violations are shown as either errors or warnings when building the project) as the path has changed.
To enable me to continue to use the 4.5RC version and my workmates to carry on using 4.4 I had to make some changes to the csproj file to cater for both:
<StyleCop4_4Path>$(MSBuildExtensionsPath32)\Microsoft\StyleCop\v4.4\Microsoft.StyleCop.targets</StyleCop4_4Path>
<StyleCop4_5Path>$(MSBuildExtensionsPath32)\StyleCop\v4.5\StyleCop.targets</StyleCop4_5Path>
</PropertyGroup>
<Import Condition="!exists($(StyleCop4_5Path))" Project="$(StyleCop4_4Path)" />
<Import Condition="exists($(StyleCop4_5Path))" Project="$(StyleCop4_5Path)" />
This disables the 4.4 target if 4.5 is installed, however if neither are installed it will fail the build trying to find 4.4. If you need to disable both if they are not installed you can replace the first import with the following:
Invoke-SqlCmd throws exception when trying to set the database via parameter
by caveman_dick on Jan.19, 2011, under PowerShell, SqlServer
This was properly doing my nut today! Basically I created a generic script to fix orphaned users and replaced the database with the standard SqlCmd variable syntax:
When running in SSMS setting the variables like this:
works fine, as it does when setting as a param to the sqlcmd.exe:
however when using the PowerShell Invoke-SqlCmd Cmdlet from the SqlServer PowerShell extensions it throws an exception that gives you absolutely no clue as to why:
Invoke-Sqlcmd : Object reference not set to an instance of an object.
At C:\Users\mayesr\Desktop\PowerShellScratchPad.ps1:22 char:14
+ Invoke-Sqlcmd <<<< -InputFile "$g_ScriptLocation\FixUser.sql" -ServerInstance "localhost" -Verbose
+ CategoryInfo : InvalidResult: (localhost:PSObject) [Invoke-Sqlcmd], NullReferenceExcep
tion
+ FullyQualifiedErrorId : ExecutionFailed,Microsoft.SqlServer.Management.PowerShell.GetScriptComm
and
I eventually noticed that the Invoke-SqlCmd has a parameter that you can set the database with. Once that was set and the use statement removed, the script worked fine! Luckily it didn’t take me too long to notice but hopefully if you come across this post it will save you some time!!
UPDATE
After I thought I had fixed this I realised that it wasn’t the Database param at all and in-fact was any param! I eventually found out there is a bug in the MSDN docs (and/or code)!! The docs say that the following format should be used:
Invoke-Sqlcmd -Query "SELECT `$(MyVar1) AS Var1, `$(MyVar2) AS Var2;" -Variable $MyArray
However this doesn’t work and the following should be used instead (remove the spaces around the ‘=’):
Invoke-Sqlcmd -Query "SELECT `$(MyVar1) AS Var1, `$(MyVar2) AS Var2;" -Variable $MyArray
I just wish I’d scrolled down to the bottom of the page as other people had added comments saying this!!
A few “features” in MSBuild that caused me pain today…
by caveman_dick on Nov.15, 2010, under Problems Solved
Today I decided to work on deploying to both our internal load-balanced app servers directly from a manually run build. Unfortunately I came across the following issues that caused me to spend far too long on this task!!
Currently I have a library of MSBuild .targets files that load in generic tasks that I can run after a build has run. One of them is a DeployWebsite task that uses a couple of Properties and can clean down and deploy the latest code from the build. I realised that all I needed to do was modify the current build to set the deploy location first. However this turned out to be a lot harder than I thought it would be…
Firstly I tried the following code which doesn’t set the Global property “AppFolderPath”:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <AppFolderPath>[INVALID]</AppFolderPath> </PropertyGroup> <Target Name="SetDeployLocation"> <PropertyGroup> <AppFolderPath>[SOME SHARE ON SERVER]</AppFolderPath> </PropertyGroup> <CallTarget Targets="DeployWebsite" /> </Target> <Target Name="DeployWebsite"> <Message Text="AppFolderPath=$(AppFolderPath)" /> </Target> </Project> |
To fix this you need to seperate the tasks into two Targets and call them from a single parent Target and set the Property using CreateProperty (not declaratively and doesn’t matter if you have already created it!):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <AppFolderPath>[INVALID SHARE]</AppFolderPath> </PropertyGroup> <Target Name="DeployToLive"> <CallTarget Targets="SetDeployLocation" /> <CallTarget Targets="DeployWebsite" /> </Target> <Target Name="SetDeployLocation"> <CreateProperty Value="[SOME SHARE ON SERVER]"> <Output TaskParameter="Value" PropertyName="AppFolderPath" /> </CreateProperty> </Target> <Target Name="DeployWebsite"> <Message Text="AppFolderPath=$(AppFolderPath)" /> </Target> </Project> |
Once I’d fixed those it still wouldn’t call the DeployWebsite multiple times. The first worked fine, however it turns out that MSBuild will not allow you to call a target with the same name twice. To get around this you can spawn a separate MSBuild task for each instance you need to run:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="DeployWebsiteToLive"> <MSBuild Targets="DeployWebsite" Properties="AppFolderPath=[SHARE ON SERVER 1];BuildDirectory=$(BuildDirectory)" Projects="$(MSBuildProjectFile)" /> <MSBuild Targets="DeployWebsite" Properties="AppFolderPath=[SHARE ON SERVER 2];BuildDirectory=$(BuildDirectory)" Projects="$(MSBuildProjectFile)" /> </Target> <Target Name="DeployWebsite"> <Message Text="AppFolderPath=$(AppFolderPath)" /> </Target> </Project> |
One thing to notice there is you need to pass across ALL properties that are not set declaratively. If you do not pass anything these are all sent across automatically, but MSBuild still detects that the two tasks are exactly the same and only runs the first one.
Hopefully you won’t have to spend as long as I did on it now!
VDPAU stops working after you upgrade the NVIDIA drivers on debian based distros
by caveman_dick on Nov.05, 2010, under Problems Solved
The last week or so I’ve been having issues with the NVIDIA drivers on my Acer Apsire Revo and had to reinstall them several times (due to a failed update of the new DKMS package breaking everything). I took the opportunity to also upgrade them to the latest version. Eventually after lots of playing around I got them to work again but my 720p videos weren’t behaving. After a bit of digging I found the vdpauinfo tool and got the following message:
“Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory”
This seemed a bit strange as I knew it was installed as I distinctly remember doing it. A bit more digging turns out that the previous installers add a symlink which what apps use instead [ref]. So it was a simple matter of adding it back in with the flowing command:
1 | sudo ln -s /usr/lib/vdpau/libvdpau_nvidia.so.1 /usr/lib/libvdpau_nvidia.so |
Hey presto everything was back to normal and the HD gods were smiling down on me!




