>Stsadm missunderstanding

>THIS IS THE WRONG WAY TO MOVE A SITE FROM ONE SERVER TO ANOTHER AT A DIFFERENT URL

On server A
———–
C:\..\BIN>stsadm -o backup -url http://serverA/ -filename c:\child.bak
Operation completed successfully.

On server B
———–
C:\..\BIN>stsadm -o createweb -url http://serverB/parent
Operation completed successfully.

C:\..\BIN>stsadm -o createweb -url http://serverb/parent/child
Operation completed successfully.

C:\..\BIN>stsadm -o restore -url http://serverb/parent/child -filename c:\child.bak -overwrite
Operation completed successfully.

stsadm -o backup / restore
————————–
Is for site collections only, the seris of commands above overwrites the root site collection on serverB. Which is absoloutly not what you intended to do.

It does not restore the backed up site to http://serverb/parent/child as you intended and as you specified -overwrite you get no warning that your root site collection is about to be overwritten.

THE RIGHT WAY TO GO ABOUT MOVING THE SITE

On server A
———–

stsadm -o export -url http://serverA/ -filename c:\child.bak -includeusersecurity -versions 4
Operation completed successfully.

On server B
———–
C:\..\BIN>stsadm -o createweb -url http://serverB/parent
Operation completed successfully.

C:\..\BIN>stsadm -o createweb -url http://serverB/parent/child
Operation completed successfully.

C:\..\BIN>stsadm -o import -url http://serverB/parent/child -filename c:\child.bak -overwrite -includeusersecurity
Operation completed successfully.

stsadm -o export / import
————————-
This does the right thing and imports the exported site to http://serverB/parent/child as you would expect

Happy days 🙂

>Generating an AD hiararchy from powershell

>I had occasion to create an AD hiarachy via script and felt it would be a good place to start my powershell learning curve. What I produced, while not the most elegant code in the powershell world, none the less does what it says on the tin. You may find it usefull.

No warranty whatsoever of course 🙂 As ever Im happy to mail the code to interested people, just mail Me

Xml file describing the hiarachy to create . This xml file describes one OU, two USERS and two GROUPS. It creates the OU and then the GROUPS then the USERS then adds Groups to groups and users to groups.

<xml>
<!–
This section describes the Active directory domain and a few locations
–>
<ad>
<domain path=”LDAP://ou=SomeOuToStartIn,dc=domain,dc=com” />
</ad>

<!–
This section lists any OU’s to be created
–>
<ous>
<ou name=”testingou” ouadspath=”LDAP://ou=SomeOuToStartIn,dc=domain,dc=com” />
</ous>

<!–
This section describes users and groups to create
and the groups users and or groups should be added to
–>
<accounts>

<group name=”group1″ grouppath=”LDAP://ou=testingou,ou=SomeOuToStartIn,dc=domain,dc=com” />
<group name=”group2″ grouppath=”LDAP://ou=testingou,ou=SomeOuToStartIn,dc=domain,dc=com” />

<user name=”testinguser1″ password=”p@55w0rd0″ userpath=”LDAP://ou=testingou,ou=SomeOuToStartIn,dc=domain,dc=com” />
<user name=”testinguser2″ password=”p@55w0rd1″ userpath=”LDAP://ou=testingou,ou=SomeOuToStartIn,dc=domain,dc=com” />

<membership location=”LDAP://cn=group2,ou=testingou,ou=SomeOuToStartIn,dc=domain,dc=com”>
<memberof>
<group location=”LDAP://cn=group1,ou=testingou,ou=SomeOuToStartIn,dc=domain,dc=com” />
</memberof>
</membership>

<membership location=”LDAP://cn=testinguser1,ou=testingou,ou=SomeOuToStartIn,dc=domain,dc=com” >
<memberof>
<group location=”LDAP://cn=group2,ou=testingou,ou=SomeOuToStartIn,dc=domain,dc=com” />
</memberof>
</membership>

<membership location=”LDAP://cn=testinguser2,ou=testingou,ou=SomeOuToStartIn,dc=domain,dc=com”>
<memberof>
<group location=”LDAP://cn=group1,ou=testingou,ou=SomeOuToStartIn,dc=domain,dc=com” />
<group location=”LDAP://cn=group2,ou=testingou,ou=SomeOuToStartIn,dc=domain,dc=com” />
</memberof>
</membership>

</accounts>
</xml>

Powershell script to create the hiarachy


## script to create ad OU’s, Groups and users
# and to add those users to predefined groups
#
#
Param ( $Filename = “accounts.xml”)

function reportStatus([string] $status)
{ Write-Debug -message $status}

function createOu{
param([string]$ouname, [string]$ouadspath)
Write-Debug -message $ouname
Write-Debug -message $ouadspath
$objDomain = [ADSI]$ouadspath
$objOU = $objDomain.Create(“organizationalUnit”, “ou=” + $ouname)
$objOU.SetInfo()
}

function createGroup{
param([string]$acname, [string]$GroupPath)
Write-Debug -message $acname;
Write-Debug -message $GroupPath;
$objOU = [ADSI]$GroupPath
$objGroup = $objOU.Create(“group”, “cn=” + $acname)
$objGroup.Put(“sAMAccountName”, $acname)
$objGroup.SetInfo()
}

function createUser{
param([string]$acname, [string]$UserPath, [string] $password)
Write-Debug -message $acname;
Write-Debug -message $UserPath;
$ADs_UF_NORMAL_ACCOUNT = 512
$objOU = [ADSI]$UserPath
$objUser = $objOU.Create(“user”, “cn=” + $acname)
$objUser.Put(“sAMAccountName”, $acname)
$objUser.SetInfo()
$objUser.SetPassword($password)
$objUser.SetInfo()
$objUser.userAccountControl = $ADs_UF_NORMAL_ACCOUNT
$objUser.SetInfo()
}

function addAccountToGroup([string] $aclocation, [string] $glocation){
Write-Debug -Message “$aclocation $glocation”
$group = [ADSI]$glocation
$account = [ADSI]$aclocation
$group.Add($account.psbase.Path)
$group.SetInfo()
}

# main code entry point
#
# read the xml file containing account information
#
$xml = new-object System.Xml.XmlDocument
$xml.Load($Filename)
# the AD node has the LDAP path we will connect to
#
$AdNode = $xml.SelectSingleNode(“xml/ad/domain”)
if($AdNode -eq $null) { return }

$AdPath = $AdNode.GetAttribute(“path”)
reportStatus (“Connecting to : ” + $AdPath)
# Create any required OU’s
#
$OuNode = $AdNode = $xml.SelectSingleNode(“xml/ous”)
if($OuNode -eq $null) { return }

reportStatus(“Create OU’s”)
foreach($ou in $OuNode.SelectNodes(“ou”)){
$ouname = $Ou.GetAttribute(“name”)
$ouadspath = $Ou.GetAttribute(“ouadspath”)
createOu $ouname $ouadspath
}

# Account creation
#
$AcNode = $AdNode = $xml.SelectSingleNode(“xml/accounts”)
if($AcNode -eq $null) { return }

# Process groups
#
reportStatus(“Create Accounts: Groups”)
foreach($ac in $AcNode.SelectNodes(“group”)){
$acname = $ac.GetAttribute(“name”)
$GroupPath = $ac.GetAttribute(“grouppath”)
createGroup $acname $GroupPath
}

# Process Users
#
reportStatus(“Create Accounts: User”)
foreach($ac in $AcNode.SelectNodes(“user”)){
$acname = $ac.GetAttribute(“name”)
$UserPath = $ac.GetAttribute(“userpath”)
$Password = $ac.GetAttribute(“password”)
createUser $acname $UserPath $password
}

# Process memberships
#
reportStatus(“Create Memberships”)
$membnode = $xml.SelectNodes(“xml/accounts/membership”)
if($membnode -eq $null) { return }

foreach($ac in $membnode){
$aclocation = $ac.GetAttribute(“location”)
$gpsnode = $ac.SelectSingleNode(“memberof”)

foreach($grp in $gpsnode.SelectNodes(“group”)) {
$glocation = $grp.GetAttribute(“location”)
addAccountToGroup $aclocation $glocation
}
}

>Biztalk server R2 upgrade woes

>Just had a misserable day and a half upgrading my XP workstation from Biztalk 2006 Dev edition to Biztalk 2006 R2 Dev edition.

To cut a very long story short. Make sure your AV software is turned off before you start otherwise the installer may hang at the stage of removing temporary files.

This happened to me and a collegue repeatedly throughout the last day and a half, rollbacks, uninstalls and re installs to no avail.
In the end, had to Rollback the R2 install, uninstall biztalk altogether then reinstall biztalk then apply R2 all this with AV turned off (Sophos was the AV in question although i’m sure any AV would have had dthe same effect)

Turns out the AV software was preventing some last steps which were crucial to a successfull install.

Happy days?