Usually when you google or do a “web search” you find a lot information how to write scripts for big enterprises and manage 100 to 1000 of servers and sometimes you have to become a little creative how you accomplish task for small business. I think it is easier to script for Small Business because they usually have one server that will host files, Exchange and Active Directory or have each role may be in a different server. Now if you are thinking to host stuff on premises think again, Office 365 is a great option for hosting your email in the cloud and if you are non-for-profit Office 365 is literally free.
I have written a script that creates user in Active Directory and then creates an Exchange Mailbox. The script can be run with admin credentials but you do not need to have the modules install on that computer. I have posted the code here
<# | |
.Synopsis | |
Creates new user in Active Directory based on Company Standards | |
.DESCRIPTION | |
Import module from Active Directory and Exchange withou the need to have the tools the installed on the computer running the commands | |
I will communicate with AD 2012 R2 and Exchange 2010 | |
.EXAMPLE | |
New-HPDCUSER -Firstname John -LastName Doe -Password SUperSecretPassword | |
#> | |
function New-CompanyUser | |
{ | |
[CmdletBinding()] | |
Param | |
( | |
# First Name | |
[Parameter(Mandatory=$true)] | |
[string]$FirstName, | |
# Last Name | |
[Parameter(Mandatory=$true)] | |
[string]$LastName, | |
#PAswword | |
[Parameter(Mandatory=$true)] | |
[string]$Password | |
) | |
Begin | |
{ | |
$ActiveDirectory = New-PSSession -ComputerName fileserver | |
Import-Module ActiveDirectory -PSSession $ActiveDirectory -Prefix RM | |
$EXchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://myexchangesererver.company.local/PowerShell/ -Authentication Kerberos | |
Import-PSSession $ExchangeSession -Prefix RM | |
} | |
Process | |
{ | |
$ou = 'OU=Users,OU=MyBusiness,DC=compny,DC=local' | |
$FullName = $FirstName + ' ' + $LastName | |
$SAM = $FirstName[0] | |
$SAM = $SAM + $LastName | |
$Password1 = ConvertTo-SecureString $Password -AsPlainText -Force | |
$UPN = $SAM + '@company.local' | |
$Path = "\\Yourfileserver\userprofiles\$SAM" | |
$Mailbox = 'Mailbox1001' | |
#Creates user in Active Directory | |
New-RMADUser -Name $FullName -DisplayName $FullName -GivenName $FirstName -Surname $LastName -Path $ou -AccountPassword $Password1 -PasswordNeverExpires $true -SamAccountName $SAM -UserPrincipalName $UPN -ProfilePath $Path | |
Add-RMADGroupMember 'SpecialGroup' $sam | |
Set-RMADUser $SAM -Enabled $true | |
#Creates Mailbox | |
Enable-RMMailbox -Identity $SAM -Database $Mailbox | |
} | |
End | |
{ | |
Get-PSSession |Remove-PSSession | |
} | |
} |
The requirements are the follow
- Exchange 2013
- Windows Server 2012 R2
- or Small Business Server 2013
If you have question on how to automated task for small business let me know. You will be surprised the amount of time you save