This is something I wrote a while back, thought I’d post it here. It does exactly what the title says. Its basically a port of the following:
http://msdn.microsoft.com/en-us/library/aa364695(VS.85).aspx
Friday, July 03, 2009
Adding outbound Windows Firewall rules using Powershell
Saturday, June 06, 2009
Media Coder Samsung P2 presets
I’ve been using Media Coder to encode videos into my P2 for a while now and its been a great alternative to what comes out of the box.
Well, all *was* great until I lost the presets for the P2! It took me an whole afternoon to reconfigure the settings that work with the P2. I’m posting the preset file here in the interest of saving someone else some time.
These setting work great for me. Your mileage may vary.
Creating “App Paths” using Powershell
I’m a big fan of Slickrun and its a tool I recommend everyone should have in their toolbox.
Unfortunately, working onsite on the client’s computers, installing third-party software is usually frowned upon. So I’ve got to make due by using the app paths.
The App Path technique of launching applications have have been around for a while. Read More:
http://www.tweakxp.com/article36950.aspx
The purpose of the script is to make the whole registry editing process a bit easier.
You can download the script here:
And execute it as such:
appPath.ps1 -key "notepad2.exe" "c:\windows\notepad2.exe"
or
appPath.ps1 -key "notepad2.exe" -path "c:\windows\notepad2.exe"
Where –key is the entry you would type in the Run dialog (please note that the extension is required). And –Path being the actual path of the file.
Disclaimer: This script modifies the registry. Use at your own risk, I will not responsible for anything that breaks as a result.
Friday, June 05, 2009
Troubleshooting Orphaned Users in SQL Server 2005 / 2008
A couple of days ago, I was tasked with moving a database from an older server to a new souped-up box. Unfortunately the transition was not as smooth as I had hoped for. After restoring the db into the new server I started running into trouble with orphaned users.
An orphaned user is basically just that, a database user without a corresponding server login. This usually happens when trying to restore a database into a new server, like what I was doing or accidently deleting the server login.
Luckily this issue can be solved relatively easy using the sp_change_users_login stored procedure.
First I get a list of orphaned users and their SIDs using the following procedure:
sp_change_users_login @Action='Report';
Next, I create the missing login from scratch (e.g. “NewLoginName”). The server mappings are not required as the database user roles are preserved in the database.
Then execute the stored procedure again with the following parameters:
sp_change_users_login
@Action='Update_One',
@UserNamePattern='dbUserName',
@LoginName='NewLoginName';
This re-jigs the broken “dbUserName” user with the newly created Server Login “NewLoginName”.
Its worth mentioning that even though there might be a login name existing on the new server identical to the database user name, they are not the same until linked together. You can find out for sure using the above stored procedure with the “REPORT” parameter.
Finally, hereare some instances where sp_change_users_login cannot be used:
- Cannot be used to map database users to Windows-level principals, certificates, or asymmetric keys.
- Cannot be used with a SQL Server login created from a Windows principal or with a user created by using CREATE USER WITHOUT LOGIN.
More information:
Tuesday, March 03, 2009
Microsoft End of Support Lifecycle Dates
Pretty Much all Microsoft Products
http://support.microsoft.com/gp/lifeselectindex
Servers - Service Packs
http://support.microsoft.com/gp/LifeSupSps#Servers
Non-Server Windows
http://www.microsoft.com/windows/lifecycle/default.mspx
Friday, December 12, 2008
Download YouTube videos using Powershell
Now that I'm back home in Sri Lanka, I'm getting re-accustomed to the slow Internet speeds over here. Slow internet speeds was the reason for me to write the YouTube downloader back in April.
So I spent a lazy afternoon today trying to port that code into Powershell. And here's the result:
How it works
The script first figures out the direct download link and then hands it off to a download manager which performs the actual download. You should be able to plug-in any download manager that supports command line arguments but I prefer to use wget for its simplicity.
Information on how the direct link is extracted can be found in my original post.
Use $downloaderPath and $downloaderArguments to configure the path of wget and its arguments respectively. The script also supports traversal through proxies and can be configured using the $proxy and $proxyPort variables.
The script accepts one parameter; the watch url of the video.
.\psVDownloader.ps1 http://www.youtube.com/watch?v=N_c60Sp7Gtc
.Please be aware that this script is purely for research purposes only. And I believe that you will be violating the YouTube TOS by trying to use its streams in ways other than intended.
Tuesday, December 09, 2008
SSRS - Unable to load client print control
One of the customer sites I work at was suddenly unable to print SSRS reports any more. This issue was occurring for only a few of their client boxes, so this rules out the possibility that it might have been a server issue.
It turns out that SSRS uses an activex control to provide some enhanced printing options. Here's some more information on it (taken from the MSDN site):
The Microsoft ActiveX control, RSPrintClient, provides client-side printing for reports viewed in a browser. The control displays a custom print dialog box that supports features common to other print dialog boxes, including print preview, page selections for specifying specific pages and ranges, page margins, and orientation.
After some investigating it looks like a conflict with KB956391. More information on it here:
http://support.microsoft.com/kb/956391
I'm guessing that this hot fix may have been pushed out by windows update, which explains it's sudden manifestation.
This is the proper way of fixing the issue; as explained in Brian Hartman's blog:
Or alternatively just uninstall KB956391.
More useful discussions on the "Unable to load client print control" issue:
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=332145&SiteID=1
http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=4006280&SiteID=17
Sunday, October 12, 2008
Abstracting underlying data sources for SSIS packages using Views
In a perfect world, we'd never have changes to the schema once it has been defined. But in practice this is almost never the case.
I stumbled upon this excellent article which provides a solution to minimize the effects of change.
http://bi-polar23.blogspot.com/2008/09/views-as-for-ssis.html
Retrieving SQL Server 2005 Product Version
Here’s the query used to retrieve the SQL Server Production Version information.
Pretty useful when diagnosing problems in multiple environments.
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition')
Storm, replacement for the aging WebServiceStudio
I am frequently required to work with 3rd party Web Services. These web services are often underdevelopment as well and more often than not tend to break our applications after each update.
I’ve been using WebServiceStudio for a while now to diagnose problems that arise after each update. WebServiceStudio was available on GotDotNet until it got shutdown and haven’t seen much updates since.
Luckily there’s a new open source tool that I discovered that replaces this aging application; Storm.
Here’s a description taken from the project site:
STORM is a free and open source tool for testing web services.
It is written mostly in F#. (I love this language!)
STORM allows you to
- Test web services written using any technology (.NET , Java, etc.)
- Dynamically invoke web service methods even those that have input parameters of complex data types
- Save development time and money. Creating throw-away test client apps just to test the web service is just too wasteful
- Test multiple web services from within one UI.
- Edit/Manipulate the raw soap requests.
- Others (Try out the tool and find out yourself!)
