Archive for the ‘Scripts’ Category.
January 25, 2012, 11:37 am
Have you seen this error before? If you’ve spent any time with the Windows Azure storage emulator it’s highly probable. Here’s the full text:
Added reservation for http://127.0.0.1:10000/ in user account COMPUTER\User.
Added reservation for http://127.0.0.1:10001/ in user account COMPUTER\User.
Added reservation for http://127.0.0.1:10002/ in user account COMPUTER\User.
Creating database DevelopmentStorageDb20110816...
Cannot create database 'DevelopmentStorageDb20110816' : CREATE DATABASE permission
denied in database 'master'.
One or more initialization actions have failed. Resolve these errors before attempting
to run the storage emulator again. These errors can occur if SQL Server was installed
by someone other than the current user. Please refer to
http://go.microsoft.com/fwlink/?LinkID=205140 for more details.
And an image of the error:

This error can occur when running the storage emulator (or running DSINIT.exe) for the first time. The compute emulator needs to initialize itself, which includes creating a local SQL Server database that is used to store data for local Windows Azure storage. The above error indicates that there’s a permissions when trying to create the database.
There are a number of ways to resolve this issue and, like others, I have my favorite approach. I have a script that I run which will add the executing user to the SQL Server sysadmin role.
I’ve published the entire script here: https://gist.github.com/1677788. Simply download and unzip the file. Open up an elevated command prompt and execute the file (i.e. run addselftosqlsysadmin.cmd). Once the script is executed the user can successfully initialize the storage emulator.
I hope this helps!
June 14, 2007, 4:46 pm
One of the more manually intense steps in the installation of Commerce Server is setting up the appropriate SQL logins and Database Role User Mapping. This task can easily take 30 – 60 minutes to complete if done manually. Futhermore, it’s likely that this is the easiest step to make a mistake, which will cause problems for you down the road.
So, to make this process quicker and less prone to errors, I’ve created an SQL script that you can run against your database. This script performs two tasks:
- Creates the SQL login accounts (e.g. COMPUTERNAMECatalogWebSvc).
- Associates the SQL login accounts to database roles.
Note: this script is only for SQL Server 2005. SQL Server 2000 uses a different set of database roles.
Take a look the Grant Web Applications and Window Services Access to the Databases section of the Installation Guide for Commerce Server 2007, and you’ll see that the number of role assignments is quite extensive.
Rather than pasting the entire SQL script into this post, I am only going to upload the .SQL file. You can modify this file as necessary in order to adapt it to your environment (e.g. changing the computer name, you may have different names for logins, or don’t need services like the direct mailer).
CreateCSLoginsAndAssignRoles.sql.txt (12.54 KB) (just remove the .txt extension)
I hope this helps!
[Update]
I found it useful to create an abbreviated verion of this script that is used for adding new sites. Whereas the script “CreateCSLoginsAndAssignRoles.sql.txt” is for brand new installations of Commerce Server 2007, the following script is useful for when you add a new site and re-use users and logins.
CreateCSLoginsAndAssignRolesForNewSites.sql.txt (8.42 KB) (just remove the .txt extension)
June 14, 2007, 3:01 pm
Holy moly, I’ve gone script crazy!
Here’s another little script that helps with the installation of Commerce Server 2007 (perhaps when I’m all done, I’ll consolidate them all into an uber-script). This script creates the Business Management Administrator Windows groups, which are used to control authorization roles within the Authorization Manager.
This script creates four Windows groups (CatalogAdminGroup, MarketingAdminGroup, ProfilesAdminGroup, and OrdersAdminGroup) and then assigns users to those groups.
Without further ado, here’s the script:
‘ ===================================================================
‘ Author: Wade Wegner
‘ Create date: 06/14/2007
‘ Description: Automate the creation and assigning of Windows Groups
‘ File Name: CreateAndAssignCSGroups.vbs
‘ ===================================================================
‘ Set the local computer name. Unlike other examples, use the computer name,
‘ rather than “.”; the AssignUserToGroup method requires the actual name
strComputer = “CS2007″
strCatalogAdminGroup = “CatalogAdminGroup”
strMarketingAdminGroup = “MarketingAdminGroup”
strProfilesAdminGroup = “ProfilesAdminGroup”
strOrdersAdminGroup = “OrdersAdminGroup”
strIISWorkerProcessGroup = “IIS_WPG”
‘ Run the Load method
Load
‘ Encapsulates the processing of this script
Sub Load()
’ Create the windows groups
CreateWindowsGroup strCatalogAdminGroup, “Catalog administration group”
CreateWindowsGroup strMarketingAdminGroup, “Marketing administration group”
CreateWindowsGroup strProfilesAdminGroup, “Profiles administration group”
CreateWindowsGroup strOrdersAdminGroup, “Orders administration group”
’ Add any users you desire
AssignUserToGroup “Administrator”, strCatalogAdminGroup
AssignUserToGroup “Administrator”, strMarketingAdminGroup
AssignUserToGroup “Administrator”, strProfilesAdminGroup
AssignUserToGroup “Administrator”, strOrdersAdminGroup
’ This adds the various service accounts to the IIS_WPG group, so that the
’ services can run as the identity for IIS app pools
AssignUserToGroup “RunTimeUser”, strIISWorkerProcessGroup
AssignUserToGroup “CatalogWebSvc”, strIISWorkerProcessGroup
AssignUserToGroup “MarketingWebSvc”, strIISWorkerProcessGroup
AssignUserToGroup “OrdersWebSvc”, strIISWorkerProcessGroup
AssignUserToGroup “ProfilesWebSvc”, strIISWorkerProcessGroup
Msgbox “Complete!”
End Sub
‘ Create the Windows group
Sub CreateWindowsGroup(groupName, description)
Set objComputer = GetObject(“WinNT://” & strComputer & “”)
Set objGroup = objComputer.Create(“group”, groupName)
objGroup.Description = description
objGroup.SetInfo
End Sub
‘ Assign the user to the Windows group
Sub AssignUserToGroup(userName, groupName)
Set objGroup = GetObject(“WinNT://” & strComputer & “/” & groupName & “,group”)
Set objUser = GetObject(“WinNT://” & strComputer & “/” & userName & “,user”)
objGroup.Add(objUser.ADsPath)
End Sub
Pretty straightforward. Nothing too fancy or flashy.
CreateAndAssignCSGroups.vbs (1.98 KB)
I hope someone fiinds this helpful!