Jump to content

Recommended Posts

Posted

Hi,

I want to launch ems and do the following command:

 

get-user %username% | set-mailbox -EmailAddressPolicyEnabled:$True

 

%username% is variable that will be passed into the command.

 

Anyone have an idea?

Thanks

Posted
Could you clarify what you are trying to achieve with the command above? Even if you used $env:USERNAME (the PowerShell equivalent to %USERNAME%) I don't think that's what you need? :confused:
Posted

ok, using this software: AD Infinitum Active Directory network administration multiple user manager tool for Windows 2000 and NT4

 

but appears to be a bug where when creating exchange 2010 accounts it doesn't apply the default email policy. Once account is created I run the above command and it fixes this.

 

speaking to developers, have the option to launch a separate program/batch after the account is created, and I can use the %username% variable from this program to pass it into the batch to run the command with the userid.

Posted

This should do it...

 

UpdatePolicy.cmd

@echo off
cd /d "%~dp0"
PowerShell -NoExit ".\UpdatePolicy.ps1" '%USERNAME%'

 

UpdatePolicy.ps1

Param([string]$UserName)
Set-Mailbox -Identity $UserName -EmailAddressPolicyEnabled:$true

 

Put both scripts in the same folder and get AD Infinitum to run the batch file.

Posted (edited)

Hi i'm getting

 

The term 'Set-Mailbox' is not recognized as the name of a cmdlet, function, scr

ipt file, or operable program. Check the spelling of the name, or if a path was

included, verify that the path is correct and try again.

Edited by zbjsy
Posted

In that case, you should be able to do something like this...

 

Param([string]$UserName)

$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://[color="#FF0000"]exchange.example.net[/color]/PowerShell/ -Authentication Kerberos
Import-PSSession $s

Set-Mailbox -Identity $UserName -EmailAddressPolicyEnabled:$true

 

or

 

Param([string]$UserName)

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
. $env:ExchangeInstallPath\bin\RemoteExchange.ps1
Connect-ExchangeServer -auto

Set-Mailbox -Identity $UserName -EmailAddressPolicyEnabled:$true

 

^ change the bit in red though.

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...