Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Friday, February 24, 2017 7:56 PM
We've got a pop3 connector that hooks up our mail server and dumps to our exchange server. It's installed on exchange server, and has it's own snapin and PS commands.
I'm trying to modify our user creation script ( to be run on IT workstations, not directly on the server ), but am having HUGE problems getting Add-PSSnapin to work.
I'm connecting to our server via:
$ExConnection = @{
ConfigurationName = 'Microsoft.Exchange'
ConnectionUri = 'http://exchange2010.domain.com/powershell/'
Authentication = 'Kerberos'
Credential = $creds
}
$Ex2010Session = New-PSSession @ExConnection
Import-PSSession $Ex2010Session -AllowClobber | Out-Null
This works fine and allows me to use exchange specific cmdlets, like new-mailbox etc.
I cannot for the life of me get Add-PSSnapin to work correctly, however. I have tried many methods:
Direct code placed before and after the session import:
Add-PSSnapin ps.pop3connex
"Add-pssnapin : The Windows PowerShell snap-in 'ps.pop3connex' is not installed on this computer."
Invoke-Command placed before and after the session import:
Invoke-Command -Session $Ex2010Session -ScriptBlock { Add-pssnapin ps.pop3connex }
"The term 'Add-PSSnapin' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again. + CategoryInfo :
ObjectNotFound: (Add-PSSnapin:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException + PSComputerName : exchange2010.domain.com
Any ideas at all? If I use enter-pssession and manually type add-pssnapin ps.pop3connex it loads fine and from that interactive session i can perform all cmdlets from pop3connex.
I am banging my head against the wall trying to figure out why I can't add-pssnapin from an imported session. All my googling leads me to people trying to import the exchange snapins themselves - an issue I am not running into.
All replies (10)
Friday, February 24, 2017 8:53 PM
If you are importing the CmdLets then there is no need to import the snapin.
"Add-pssnapin : The Windows PowerShell snap-in 'ps.pop3connex' is not installed on this computer."
\(ツ)_/
Friday, February 24, 2017 9:03 PM
I am not sure what you're saying. I need to import the snapin to get access to the cmdlets. Obviously, the "add-pssnapin: the windows powershell snap-in 'ps.pop3connex' is not installed on this server" is the error. I am not sure why you're echoing it back - it's the issue I'd like to fix.
I need to import the snapin to get access to the cmdlets to finish my script....
Friday, February 24, 2017 9:22 PM
Snap-ins are not imported - they are added and must first be installed and registered. Using the web service we don't need the snap-in because we can import the session which imports the CmdLets. You can do one or the other but not both.
TO see what snap-ins are installed type "Get-PSSnapin -Registered"
\(ツ)_/
Friday, February 24, 2017 9:42 PM | 1 vote
Forgive my verbiage, but isn't that exactly what I am doing? I said import, but obviously I meant add.
If you actually look at my code, you can see I create a session and then import it. Using Invoke-command before the import i attempt to add the snapins to the session. Then import said session. During my Invoke-Command scriptblock I get
"The term 'Add-PSSnapin' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again. + CategoryInfo :
ObjectNotFound: (Add-PSSnapin:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException + PSComputerName : exchange2010.domain.com"
I am not sure if you actually read my post or just started with my miscommunication of 'importing snapins.'
writing out the results of get-pssnapin -registered results in this: Dell.OME.CLI Microsoft.Exchange.Management.PowerShell.E2010 Microsoft.Exchange.Management.Powershell.Support VMware.DeployAutomation VMware.ImageBuilder VMware.VimAutomation.Core
Obviously no ps.pop3connex there.
To be ultra super damned clear - I am creating a session on a remote exchange host, i am trying to load a snapin that is located on that machine, and then import the session. This is NOT working for me as my code and pasting is showing.
If i use an interactive shell, via enter-pssession, it all works just fine.
I feel like I am just retyping my exact post, so forgive me if I am missing something obvious. I don't think you fully read my post, however.
Friday, February 24, 2017 10:08 PM
I'll try again.
This is how to connect to Exchange and run the CmdLets:
**$Ex2010Session = New-PSSession @ExConnection**
Import-PSSession $Ex2010Session -AllowClobber
You now have the CmdLets. Thee is no need to use Invoke or Add-PsSnapin
You cannot remotely add a snap-in using Invoke. The exchange session prohibit you from doing that.
Note also that Exchange 2010 is no longer supported. It has been out of support for 2 years.
\(ツ)_/
Friday, February 24, 2017 10:29 PM
I really wish I could be more clear. That is exactly how I connect, and exactly the expected behavior. It is NOT, however, what is happening in my case.
I get access to all the exchange cmdlets. I do not, however, get access to the third party cmdlets provided in ps.pop3connex. I have tested this repeatedly, and just tested again with the following code:
$ExConnection = @{
ConfigurationName = 'Microsoft.Exchange'
ConnectionUri = 'http://exchange2010.domain.com/powershell/'
Authentication = 'Kerberos'
Credential = $creds
}
$Ex2010Session = New-PSSession @ExConnection
Import-PSSession $Ex2010Session -AllowClobber
$p3xconnector = Get-P3XConnector #this is a cmdlet from ps.pop3connex
$getpssnapin = Get-Pssnapin -Registered #verification of loaded snapins
$justin = get-mailbox -identity 'justin' #test to make show ex cmdlets work
Write-Host $p3xconnector
Write-Host $getpssnapin
Write-Host $justin
And this is the result:
Get-P3XConnector : The term 'Get-P3XConnector' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and tryagain.
At \path\scripts\exchange\p3x\usercheck.ps1:40 char:17
- $p3xconnector = Get-P3XConnector
- ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-P3XConnector:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Dell.OME.CLI Microsoft.Exchange.Management.PowerShell.E2010 Microsoft.Exchange.Management.Powershell.Support VMware.DeployAutomation VMware.ImageBuilder VMware.VimAutomation.Core
Justin Allen
As you can see, it is not loading or using the p3x snapins. To me, this is expected behavior if I do not load the snapin. If I RDP into the server itself and start the EMS directly on the server and type: get-p3xconnector I will receive the same 'term is not reconized cmdlet or function' unless I load 'add-pssnapin ps.pop3connex' beforehand. The instructions with pop3connex are also clear on that, and every other product I've used that had their own bundled snapins required you to load them. I am unsure how you are so confident that simply starting a session on a box will load all potential snapins without actually specifying and loading them yourself. Even the VmWare docs and guides show that my method is used very often:
| $session = New-PSSession -ComputerName "NameOfConnectionServer" |
With remoting enabled, a session is opened to the connection server from a workstation. A session is a persistent connection that can be referenced when using subsequent remoting commands.
| 1 | Invoke-Command -Session $session -ScriptBlock {Add-PSSnapin VMware*} |
The VMware cmdlets aren’t loaded by default, so Invoke-Command is used to tell the PowerShell session on the remote server to load the VMware snapin.
Friday, February 24, 2017 11:08 PM
Start by realizing that you are not running EMS when you remote into the server. You are attaching to a remote session endpoint for Exchange. It does not allow you to load any components but the ones defined for the endpoint.
Contact the vendor of the third party components to find out how to use them remotely if it is possible. If you are suing the exchange endpoint they will not work. The common PowerShell remote endpoint may work with the third party CmdLets but will not allow you to load the Exchange Snap-in.
\(ツ)_/
Saturday, February 25, 2017 12:07 AM
Thank you, do you have any docs or links to the remote endpoint being so locked down? That bit of knowledge is all I needed. What I'm doing is sane and something I've done multiple times before - just never on exchange. I have also attempted to connect 'traditionally' by not using the http interface, and experience the same results. I was not aware exchange had further locked down PS remoting.
Saturday, February 25, 2017 12:30 AM
I have no links. I am going from memory as I haven't worked with EX2010 for at least 2 years.
You might start here: https://blogs.technet.microsoft.com/rmilne/2015/01/28/directly-loading-exchange-2010-or-2013-snapin-is-not-supported/
Search for more old articles and blogs. Do it now as they are disappearing fast.
Better upgrade before it is too late.
\(ツ)_/
Saturday, February 25, 2017 3:33 PM
Hey -- Nice blog - it had better not be disappearing, as not one told me anything about that :)
For Justin, go to that blog and read these series of articles please:
You are doing this correctly with regards to Exchange Remote PowerShell, and what I see below is all good for Exchange. But not so good for your third party stuff.
'
Quoting:
We've got a pop3 connector that hooks up our mail server and dumps to our exchange server.It's installed on exchange server, and has it's own snapin and PS commands.
I'm trying to modify our user creation script ( to be run on IT workstations, not directly on the server ), but am having HUGE problems getting Add-PSSnapin to work.
I'm connecting to our server via:
$ExConnection = @{
ConfigurationName = 'Microsoft.Exchange'
ConnectionUri = 'http://exchange2010.domain.com/powershell/'
Authentication = 'Kerberos'
Credential = $creds
}
$Ex2010Session = New-PSSession @ExConnection
Import-PSSession $Ex2010Session -AllowClobber | Out-Null
This works fine and allows me to use exchange specific cmdlets, like new-mailbox etc.
I cannot for the life of me get Add-PSSnapin to work correctly, however. I have tried many methods:
Direct code placed before and after the session import:
Add-PSSnapin ps.pop3connex
What you need to understand is that there are two runspaces, the client and server. This is all discussed in my blog articles.
Your PSSNAPIN is installed on the exchange server. You cannot call that from the workstation, since the add-pssnapin is not available locally.
Is there an admin tools install for this 3rd party tool? If so then, install that onto the workstations in question.
Cheers,
Rhoderick
Microsoft Senior Exchange PFE
Blog: http://blogs.technet.com/rmilne Twitter:
LinkedIn:
Facebook:
XING:
Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.