Quickly Exporting of Certificates via PowerShell

As I was doing some work with Sitecore Automation Framework, I needed to quickly export certificates from my local store.  Here is the quickest way that I could come up with.

ls | ?{ $_.FriendlyName -match "_SAF$" } | %{ Export-PfxCertificate -Cert $_ -FilePath "C:\<projroot>\infra\configuration\Local\$($_.FriendlyName).pfx" -Password (ConvertTo-SecureString -String "1234" -Force -AsPlainText) }

Maybe there is a nicer way to do that but that’s what comes to mind.

Advertisement

Modifying user path w/o Admin rights

Just the other day I was asked by a colleague, ” if our corporate laptops are protected that we do not have admin privileges, how are you able to do any development work?  I cannot do anything”.

That’s a great question.  However, MS Windows OS has gone over a few transformations and a lot of applications are written in a way that promotes usage w/o elevation.  Yet, some basic things are still puzzling. For example, user path variable.  The system path should be protected as it is set by admin installation of programs etc, but changing path for a user to ensure that one application can be started quickly w/o knowing the full path should be simple. But, it is anything but simple.

Going to User Accounts is not an option as you will quickly get an error screen either due to elevation restriction or basic GPO set by IT.  But there is another way. You can utilize the rundll32.exe to invoke the GUI directly.


rundll32 sysdm.cpl,EditEnvironmentVariables

I’ll continue exploring more ways to manage my workstation w/o elevation as i spend more time living with new fun policy.

Managing Azure dev environment from PowerShell

Recently, I’ve been spending some time prototyping the new SharePoint 2013 App Model in my Azure provision SP2013 development environment.  I wanted to make sure that i can shut it down or start it up quickly.  So PowerShell is of course the answer here.

Small assumption is that the Azure Service Name matches the Virtual Machines. It is possible to have multiple virtual machines provisioned under the same service Name

First, ensure that the valid Azure subscription is attached to the Azure command line session:

Get-AzureAccount

If that returns no subscriptions, then use Add-AzureAccount commandlet to add an active subscription.
To start/stop the Azure Virtual Machines I use these commands:

Get-AzureVM -ServiceName <ServiceName> | Start-AzureVM
Get-AzureVM -ServiceName <ServiceName> | Stop-AzureVM -Force:$true

I’ll add more commands as i start doing more complex things with Azure dev boxes as I go along.

Quickly updating SharePoint 2010 service account

At my current client, I run a sandbox SharePoint 2010 single server environment on top of Windows 7 with my corporate credential as my service account.

I get a wonderful message saying that my account password is about to expire, so obviously, my heart goes thumping. Here we go again.  It’s time to lose more hours on running around and switching around password within SharePoint 2010 that powers all the web apps, service apps, etc…

However, as per my colleague suggestion, it turned out to be pretty easy:

  1. Change your corporate account password using Ctrl+Alt+Delete -> Change Password
  2. Run the following command in PS to quickly update everything else.
$cred=get-credential;Set-SPManagedAccount -Identity $cred.Username -ExistingPassword $cred.Password -UseExistingPassword

Restart the IIS via “iisreset /noforce” and you’re all set.

View SharePoint Deployment progress

There are many instances where our team would deploy the SharePoint solutions through management shell and then opens the Central Administration in the browser to see the deployment progress.
It’s much easier to just write a one liner to see the status instead.

   1: get-SPSolution SampleSolution | Select Last* | format-list