exchange snapin problem

Dan
Dan used Ask the Experts™
on
why is it that everytime I open up exchange shell, I have to type the following command, or I get the error "the term "command" is not recognized as the name of a cmdlt....."

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn;

Is there a way to have this stick, so I don't have to do this every time I open the exchange shell?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Justin YeungSenior Systems Engineer
Commented:
did you try run as administrator?
DanNetwork Engineer

Author

Commented:
yes, even when I run as administrator, still get the same error.
Jose Gabriel Ortega CastroTop Rated Freelancer on MS Technologies
Awarded 2018
Distinguished Expert 2018

Commented:
Use the icon "Exchange Management Shell" that would make the psnapin load of that for you.

emc.png
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

DanNetwork Engineer

Author

Commented:
yes, that's the icon I always use
shell
Nicky RavenTechnical Services Analyst
Commented:
I have a template that use to connect to our exchange from my system that is unambiguous so you could change this to your liking. (see below)

I have the Exchange console installed on my system as that is where the snap-in is located so you may need to do the same.. see the link for how to do this on a system other than the exchange server as it is already installed ther

Local Exchange 2010 install for windows 7

## Ask for Users Credential
$UserCredential = Get-Credential
$PSDefaultParameterValues = @{"*-AD*:Credential"=$UserCredential}

## This Pice of code goes thugh the snapin's for each of the differant enviroments for extedned use on the exchnage server
## Exchnage 2007 ##
if ((Get-PSSnapin | ? { $_.Name -eq "Microsoft.Exchange.Management.PowerShell.Admin" }) -eq $null) {
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin -ErrorAction SilentlyContinue}

## Exchnage 2010 ##
if ((Get-PSSnapin | ? { $_.Name -eq "Microsoft.Exchange.Management.PowerShell.E2010" }) -eq $null) {
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue}

## Exchnage 2013 & 2016 ##
if ((Get-PSSnapin | ? { $_.Name -eq "Microsoft.Exchange.Management.PowerShell.Snapin" }) -eq $null) {
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Snapin -ErrorAction SilentlyContinue}

## Active Directory Module add code
function Check-LoadedModule
{ Param( [parameter(Mandatory = $true)][alias("ActiveDirectory")][string]$ActiveDirectory)
  $LoadedModules = Get-Module | Select Name
  if (!$LoadedModules -like "*ActiveDirectory*") {Import-Module -Name ActiveDirectory}}

## Exchnage Server Connection
$ExchName = Get-ADGroup -Identity "Exchange Servers" | Get-ADGroupMember | where {$_.objectclass-eq "computer"} | select -ExpandProperty NAME
$Domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().Name

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$ExchName.$Domain/PowerShell/ -Authentication Kerberos -Credential $UserCredential
Import-PSSession $Session -AllowClobber


<# Exchnage Code  for what you want to do to go Hear #>


Remove-PSSession $Session

Open in new window


Hopefully this help

regards
HizShadow
DanNetwork Engineer

Author

Commented:
I'm running the exchange management shell ON the Exchange server, not on any other computer, that's why I find it very strange that I have add the snapin every time I run the program.
Jose Gabriel Ortega CastroTop Rated Freelancer on MS Technologies
Awarded 2018
Distinguished Expert 2018

Commented:
Well what is happening with exchange server, it's that it does PSREMOTING into the "exchange server" sometimes it doesn't work, and when it fails you need to add the snap-in manually to get it working, when you click the exchange management console ( which is a shortcut it load the snaping behind scenes, if it fails, you need to do it manually).
DanNetwork Engineer

Author

Commented:
Well, whatever it's suppossed to do behind scenes, it's not working, it fails everytime.   So is there a log I can look at to see why it's failing?
There has to be a reason, it's strange for it to fail every time I start the management console.
Jose Gabriel Ortega CastroTop Rated Freelancer on MS Technologies
Awarded 2018
Distinguished Expert 2018

Commented:
DanNetwork Engineer

Author

Commented:
I am running exchange 2013, not 2007.
I just restarted the server, tried to open the exchange toolbox and I get this error message:
"the term 'get-queue' is not recognized as the name of a cmdlet, function, script file, or etc...."
So I'm logged on my exchange server directly, with full domain admin rights.
This is poor programming on MS, I'm sorry.  I'm just so tired of MS.

So I manually in the exchange shell, ran the command,
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn;

It was successful, but when I go to open up the toolbox, I'm still getting that error message.

So what do I do next?
Jose Gabriel Ortega CastroTop Rated Freelancer on MS Technologies
Awarded 2018
Distinguished Expert 2018
Commented:
The toolbox should load the snapin by itself.
if you go to the ps console and run the add snap-in, don't expect the toolbox to run. that's not how it works.

If you open a poweshell console and run commands, they are alive in that "particular Session" you can't transfer the loaded snap-in between windows or tools, they are session independent, this doesn't work like the operating system.

If your exchange toolbox doesn't work, you should go to the event viewer and start looking at the errors and warnings there.
DanNetwork Engineer

Author

Commented:
Yes I know that  if I run the command in the shell, it doesn't apply to the toolbox, but I thought it's worth it :)
That's why I even restarted the server.  I looked through the event log and there's nothing there that looks like it's something causing a problem.
IT Engineer
Distinguished Expert 2017
Commented:
Check you installation directory
C:\Program Files\Microsoft\Exchange Server\V15\Bin
If you have all scripts available in this location (or maybe one of file is corrupted)

Capture.JPG
If not please copy from installation media directly to your Bin Folder.
You can find files on your installation DVD   \setup\serverroles\common:

If you don't have it, I can zip it for you
DanNetwork Engineer

Author

Commented:
Tom, I have every file that you listed in my bin folder.  I just double checked.

At this point, it's not worth my time to try to recopy the files, as I'm planning to install EX2016 tonight on a new server.
DanNetwork Engineer

Author

Commented:
Thanks everyone for your input,

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial