Thursday, February 26, 2015

Dot Sourcing variable and functions in Powershell

What I sometimes have trouble with is dot sourcing the ps1 files.  Dot sourcing a file allows the variables and functions to be available after the script has run.

A simple demo of this is to create a .ps1 file containing the following:

We then run this .ps1 file within powershell.  When we then try to use the variable $a, nothing happens, as the variable is removed when the script finishes.

To dot Source the file, use the command:
. .\Test-DotSourcing.ps1
Notice the dot space dot backslash syntax.

The variable $a is now available within that session.

To use Dot sourcing with a function, consider the following function:

function test-DotSourcing2 {

We can use this by firstly Dot sourcing the .ps1 file as normal, then calling the function name directly (remove the .ps1 extension). 

The function name will also be available in tab completion.

Thursday, February 19, 2015

Thursday, February 12, 2015

Modify Send As Permission Exchange 2010

Open Exchange Management Console


Click Yes on the User Account Control Dialog if it appears

On the left hand side of the screen, navigate to Microsoft Exchange -> Microsoft Exchange On-Premises -> Recipient Configuration


Select Mailbox

Right click on the users mailbox you wish to send on behalf, and select Manage Send As Permission…

Click Add…


Select the name of the user you wish to give access to, and click OK

Click Manage

Click Finish   You can also accomplish this by using Powershell.  In this example, Andrew will be given Send As permission on Craig’s mailbox:

Add-ADPermission Craig -User Andrew -ExtendedRights "Send As"

You can also use groups.  In the example below, the group called Sales Users will be given Send As
permission on Craig's mailbox:

Add-ADPermission Craig -User "Sales Users" -ExtendedRights "Send 

To removing Send As:

Remove-ADPermission Craig -User Andrew -ExtendedRights "Send As"

This will prompt for confirmation, and the confirmation warning is a bit counter intuitive:

Are you sure you want to perform this action?
Removing Active Directory permission "Craig" for user "Andrew" with access rights "'Send As'".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): y

This means that this will remove Andrew's send as permission on Craig's mailbox.

Wednesday, February 4, 2015

Uninstall Pokki for All Users

(Edit 24/02/15 - corrected registry location)

Lenovo were preinstalling a Start Menu replacement on Windows 8 called Pokki.  Uninstalling this works for a single user, but as soon as another user logs in, the application is reinstalled.  This is not listed as Metro application that can be uninstalled using remove-appxpackage or remove-appxprovisionedpackage, as listed here (new window).

To uninstall this for all future users (This will not delete it for any users that have already created profiles, they will need to be done individually – see the end for more details):

Go into Programs and Features, and uninstall it like any other application

Yes choose to uninstall

Go into the \users\public folder, and delete the pokki folder

You will need to show hidden files and folders (see here for instructions - new window), and go in to the \users\default\appdata\local folder, and delete the pokki folder

Open regedit as ad administrator, select HKEY_USERS, click the file menu and select Load Hive…
Navigate to \users\default and select NTUSER.DAT

Give the hive a name, eg: pokkiDefault and click OK

Navigate to HKEY_USERS\pokkiDefault\Software\
Delete the POKKI key

Navigate to HKEY_USERS\pokkiDefault\Software\Microsoft\Windows\CurrentVersion\Run
Delete the Pokki string value

Select the HKEY_USERS\pokkiDefault key, select the file menu, and Unload hive… and select yes.

This will not delete pokki from profiles that are already created.  You can however delete the pokki files from each user profile, and use the regedit method above to load the other users hive and remove it from their startup.  I haven’t tried it but would also look at removing it from their Programs and Features list via this method: and also looking in their hive at the equivalent HKCU registry location.