Hi,
I have a project to centralized management of all my Microsoft products : AD, Exchange, SharePoint and Lync for the moment. So I installed a Windows 2012 R2 server (core) dedicated to PowerShell administration. With the help of tommymaynard on this forum, I configure my PSWA to work like I wanted to. But now it’s time to scripting what I need to do.
My question is what’s the best way for me to start.
It is better to create a series of personal cmdlet (function) and did module with it or it is better to write big full script for all big action I need to do ?
I’m not sure I’m clear. ![]()
For example, create a new AD user. What’s the best : Create cmdlet for each action with specific parameters to me and put this cmdlets in a little script or write a big script with all actions I need to perform to create a user.
Another thing, it is a good idea to put a menu in the script? I did some and I want to know if it’s a good or not. If it’s yes, did I do it the best way? See my example:
function Set-EmailAddress{
$accountmodify = Read-Host "Enter the USERNAME of the account you want to ADD or REMOVE email address"
$listemailadd = Get-Mailbox -Identity $accountmodify | Select -expand emailaddresses alias
Write-Output "This is the list of all email address for the account $accountmodify"
Write-Output $listemailadd
$emailadd = Read-Host "Entrer the email address you want to add or remove"
echo "--------------------------------------------"
echo ""
echo ""
echo " 1. ADD a email address TO $accountmodify"
echo " 2. DELETE a email address FROM $accountmodify"
echo " 3. Return to main menu"
echo ""
echo "--------------------------------------------"
$answeremailadd = Read-Host "Please make your selection"
if ($answeremailadd -eq 1){Set-Mailbox $accountmodify -EmailAddresses @{add=$emailadd}}
if ($answeremailadd -eq 2){Set-Mailbox $accountmodify -EmailAddresses @{remove=$emailadd}}
if ($answeremailadd -eq 3){Get-MainMenu}
Get-MainMenu
}
Thank’s in advance for your feedback and advice.
Jeremie