PowerShell; SharePoint 2010: Set Alternate Access Mapping

I need to set Alternate Access Mapping remotely as part of my automation. I can’t find how to specify PowerShell version for Invoke-Command CMDlet. So I decided to use this workaround:


Invoke-Command -computer sp2010.vlasenko.org -script {
  $command = "Add-PSSnapin Microsoft.SharePoint.PowerShell; New-SPAlternateURL 'http://vlasenko.nmsp.org' -Zone 'Internet' -WebApplication 'SharePoint - 80'"
  PowerShell -v 2 -Command "& { $command }"
}

Howto change IBM Connections 4.5 hostname?

Have created the IBM Connections 4.5 image. Now I need to be able to clone it.
C:\IBM\WebSphere\AppServer\profiles\Dmgr01\bin>

  1. Command to check you WAS node hostname:
    wsadmin.bat -user wasadmin -password pa$$word-c "$AdminConfig show (cells/CONNECTIONSCell01/nodes/CONNECTIONSCellManager01|serverindex.xml#ServerIndex_1)
    hostName"

    Command to change WAS node hostname:

    wsadmin.bat -user wasadmin -password pa$$word -c "$AdminConfig modify (cells/CONNECTIONSCell01/nodes/CONNECTIONSCellManager01|serverindex.xml#ServerIndex_1) {{hostName myconnections.acme.org}}"
  2. I’ve also changed C:\IBM\WebSphere\AppServer\profiles\AppSrv01\config\cells\CONNECTIONSCell01\LotusConnections-config\LotusConnections-config.xml to reflect changes in the hostname

But it still doesn’t work 😦
connectionsHostNameIssue
Do you have any ideas?

Ubuntu: Attach EBS Volume & Mount it to a directory

Assume you have installed AWS Command Line Interface and you instance is started with appropriate AWS IAM Role (so you don’t need explicitly provide credentials).
—-

#!/bin/bash
# 1. Make a directory to serve as a mount point
mkdir -p /data
chown `id -u` /data
# 2. Attach EBS volume to the instance
export AWS_DEFAULT_REGION=us-east-1
VolumeId=$(aws ec2 describe-volumes --filters Name='tag:Name',Values='My Back-End' | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["Volumes"][0]["VolumeId"]')
InstanceId=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
aws ec2 attach-volume --volume-id $VolumeId --instance-id $InstanceId --device /dev/xvdf
ls /dev/xvdf
# 3. Wait till volume attached to the instance
while [ $? -ne 0 ]; do
sleep 5
ls /dev/xvdf
done
# 4. Mount the volume
mount -a /dev/xvdf /data

—-
BTW: Why do I need this? I want to use AWS EC2 Spot Instance for my PostgreSQL. So I had to come up with solution to persist data when my instance is terminated. I decided to go with AWS EBS volume.

UPDATE: PosrgreSQL available as AWS RDS. So you don’t need to use solution above in case of PostgreSQL.

Creating an AWS Account

Source: http://docs.aws.amazon.com/AmazonSimpleDB/latest/DeveloperGuide/AboutAWSAccounts.html
To access any web service AWS offers, you must first create an AWS account at http://aws.amazon.com. An AWS account is simply an Amazon.com account that is enabled to use AWS products; you can use an existing Amazon.com account login and password when creating the AWS account.
Important
If you have a personal Amazon.com account, you might want to have a separate Amazon.com account just for your AWS activity. You could provide a new e-mail address not already in the Amazon.com system, or provide an e-mail address for an existing Amazon.com account you have but use a different password. You can have multiple Amazon.com accounts that use the same e-mail address, but different passwords.
From your AWS account you can view your AWS account activity, view usage reports, and manage your AWS Security Credentials.
To set up a new account

  1. Go to http://aws.amazon.com, and then click Sign Up.
  2. Follow the on-screen instructions.

Part of the sign-up procedure involves receiving a phone call and entering a PIN using the phone keypad.

PowerShell: Register AWS EC2 instances in AWS R53

UPDATE: #PowerShell: Register AWS EC2 instances in Amazon Route 53 (new way)

Suppose you have a variable $lab:

$lab = @{id='ami-7300091a'; name='1.dc.mylab.com'; type='m1.small'; maxbid='0.02'; CNAME='ec2-54-000-117-7.compute-1.amazonaws.com'},
@{id='ami-49000e20'; name='1.sql.mylab.com'; type='cc1.4xlarge'; maxbid='0.09'; CNAME='ec2-184-73-000-182.compute-1.amazonaws.com'}

Let’s update AWS R53 entries by using instances CNAME:

$zoneId = 'ZB00X5FI00YBB'
foreach($computer in $lab){
  "[$($computer.name)]`t[R53] update... " | Out-Default
  $result = Get-R53ResourceRecordSet -HostedZoneId $zoneId -StartRecordName $computer.name -MaxItems 1
  $rs = $result.ResourceRecordSets[0]
  if($rs.Name -eq "$($computer.name).") {
    "[$($computer.name)]`t[R53] entry found" | Out-Default
    "[$($computer.name)]`t[R53] delete entry" | Out-Default
    $action = (new-object Amazon.Route53.Model.Change).WithAction('DELETE').WithResourceRecordSet($rs)
    Edit-R53ResourceRecordSet -HostedZoneId $zoneId -ChangeBatch_Changes $action | Out-Null
  } else { "[$($computer.name)]`t[R53] entry not found (returned entry is for $($rs.Name))" | Out-Default }
  "[$($computer.name)]`t[R53] create entry" | Out-Default
  $record = (new-object Amazon.Route53.Model.ResourceRecord).WithValue($computer.CNAME)
  $rs = (new-object Amazon.Route53.Model.ResourceRecordSet).WithName($computer.name).WithType('CNAME').WithTTL('10').WithResourceRecords($record)
  $action = (new-object Amazon.Route53.Model.Change).WithAction('CREATE').WithResourceRecordSet($rs)
  Edit-R53ResourceRecordSet -HostedZoneId $zoneId -ChangeBatch_Changes $action | Out-Null
}