25 June, 2013

PowerShell and C#: Can’t load MSOnline module

Crazy stuff, this PowerShell.

I was doing a C# program that needed to load in a PowerShell module with cmdlets intended for Office365. Even I had installed the x64 version of this module; it never showed up the proper place on the hard disk meaning my program failed to load it. Driven by a post on a forum somewhere on the WWW; I tried the following trick which actually worked to my surprise.

I’m running a x64 OS currently (Win8 Pro).

Copy the folder MSOnline from (1) –> (2) as seen here

1) C:\Windows\System32\WindowsPowerShell\v1.0\Modules\(MSOnline)

2) C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules\(MSOnline)

After doing this trick, your x64 bit OS will happily load-in the MSOnline PS module into your runspace in your C# program.

    var iniSS = InitialSessionState.CreateDefault();
iniSS.ImportPSModule(
new[] { "MSOnline" });

var rs = RunspaceFactory.CreateRunspace(iniSS);
rs.Open();

m_PowerShell =
PowerShell.Create();
m_PowerShell.Runspace = rs;

//credentials
SecureString ss = m_PowerShellPwd.ConvertToSecureString();

var connectCmd = new Command("Connect-MsolService");
connectCmd.Parameters.Add(
"Credential", new PSCredential (m_PowerShellUsr, ss));

//add to ps
m_PowerShell.Commands.Clear();
m_PowerShell.Streams.Error.Clear();
m_PowerShell.Commands.AddCommand(connectCmd);

//connect
m_PowerShell.Invoke();
var err = m_PowerShell.Streams.Error.ReadAll();

19 June, 2013

Manage all shares on PC/Server

When one forgets where to manage all shares (if a folder has been deleted but still exists as a share), it can be deleted here.
Just a point of reference when one forgets where that’s managed (as I did!)

image

Change (telephone) association in Windows 8

So, I accidently happened to associate the TEL extension in the People application to Lync when I meant to associate it to Skype instead. Unfortunately, having done that it does no longer allow me to change that (or so it appears).

The place to change that association is seen below (or so I discovered).

image

Change the association here and you are good to go.

iPhone/XCode - not all cases are equal!

This bit me! Having made some changes to an iPhone application (Obj-C); everything worked fine in the simulator. But, when deploying the s...