cancel
Showing results for 
Search instead for 
Did you mean: 

Powershell - How do I format my script?

ChrisBrown
Level 2

Hi,

How do I format my script that I have to run within the Powershell object? 
I have one data item I wish to use [User Logon Name] and this needs to be used in the script to generate the Remote Mailbox, and set a locale.

I'm not sure how to format the code to ensure that it works and what needs to wrap around the [User Logon Name].

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://EXCH-01/PowerShell/
Import-PSSession $Session -AllowClobber -DisableNameChecking | Out-Null

Set-ADServerSettings -ViewEntireForest $true

cls

Enable-RemoteMailbox -Identity [User Logon Name] -Alias [User Logon Name] -RemoteRoutingAddress "[User Logon Name]@domain.mail.onmicrosoft.com"
Set-ADUser -identity [User Logon Name] -replace @{ 'preferredlanguage' = 'en-GB'}

Remove-PSSession $Session

Thanks, Chris

2 REPLIES 2

Michael_S
Community Team
Community Team

Hello @Chris Brown!

How are you getting on with this? I'm going to move your question over to the Digital Exchange Community as the Powershell VBO is supported primarily through that space. I'll also bump it to the top for you to see if we can get some of our code pros on the case.

Good question!

MatHanley
Level 2

Find and replace your variables before you run the script? 

Simple Example 

35917.png