Avatar of timgreen7077
timgreen7077
 asked on

Exchange 2016 Management Shell

Is there a way to load Exchange 2106 Shell to run instead of plain powershell. This will be a scheduled task, but it seems to need EMS instead of powershell only.
PowershellExchange

Avatar of undefined
Last Comment
Jose Gabriel Ortega Castro

8/22/2022 - Mon
Alan

Hi,

I think you mean you want to run 'Exchange Management Shell'?

Is that correct?

Alan.
timgreen7077

ASKER
Yes it's the exchange management she'll. but it's exchange 2016 and the exchange ps snapin isn't supported.
ASKER CERTIFIED SOLUTION
Jakob Digranes

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jose Gabriel Ortega Castro

You just need to load within the ps script the snapin

#Load Exchange pssnapin it's not loaded
if (-not (Get-PSSnapin | Where-Object {$_.Name -like "Microsoft.Exchange.Management.PowerShell.E2010"})){ 
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 
}
else{
	write-log -level Load -Message "The Exchange PS Snap-in is already loaded"
}

Open in new window


Can be 2010 or 2013. it would work.
Add those lines before actually doing the PS exchange cmdlets calls.
https://social.technet.microsoft.com/wiki/contents/articles/38580.configure-to-run-a-powershell-script-into-task-scheduler.aspx
https://social.technet.microsoft.com/wiki/contents/articles/46768.how-to-run-a-powershell-script-with-parameters.aspx
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
timgreen7077

ASKER
Jose, it's Exchange 2016. That is what I'm inquiring about. Not 2010 / 2013.
Jose Gabriel Ortega Castro

It doesn't matter.
what i meant was if you use this line
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010

IT will work for any exchange version, like 2010,2013 and 2016. did you even try it ?.