Posts Tagged ‘powershell’

Powershell is coming … you can’t run … you can’t hide and you should brushup/learn your syntax as well

May 14, 2010

This This post

Gave me some clues on powershell that were badly needed.

The sitch:

i)   I’m upgrading SharePoint 2007/2010 in place (yip don’t start I was just trying to see what happened).
ii)  Started getting an error that implied that the security privileges of the admin account weren’t in sync.
iii) I wanted to reset the passwords in SharePoint system to those currently set in the AD system.

What I did

i) Booted up the SharePoint 2010 Management Shell (powershell) (stsadm had stopped working at this stage as I was literally mid-upgrade: SP2010 installed but not ‘upgraded’).
ii) Get-Help Set-SPManageAccount (Get-Help is pretty much like ‘man’ from linux in powershell land it is actually useful and tells you how to use all the commands you find along the way).
This link provided me with the information I needed to kick start the relevant commands link.

iii) Having marshaled all this info together you need to start wrestling with the syntax of the parameter options (of which there are many). Long story short make sure you look up each of the parameter types specified and then the relevant pieces of powershell to weave your plain text strings (which you were used to from good ‘ol command line) into strongly typed parameters.

$currentPassword = convertto-securestring “passwordTextjkfdajlkadsj” -asplaintext -force  (converts plain text password into a ‘secure-string’ variable)

Set-SPManagedAccount -Identity “domain\username” -ExistingPassword $currentPassword -UseExistingPassword.

It’s worth mentioning in the above.

i)  $currentPassword represents a variable defined in the first line and used in the second.
ii) -UseExistingPassword is a ‘switch’ parameter that doesn’t need to be defined other than its presence will ‘switch’ the input from the default (often false value I think) to the opposite ‘true’.

Still wresting with this upgrade so I gotta go now … good luck !!