Answer the question
In order to leave comments, you need to log in
Why does the function work incorrectly when loaded from a module?
There is a function in the module:
function Connect-Exchange {
[Cmdletbinding()]
param(
[Parameter(Mandatory = $false)]
[string]$URL = (Get-Content $HOME\.psvariables\exchangeserver)
)
Import-PSSession -Verbose (New-PSSession -Verbose -ConfigurationName Microsoft.Exchange -ConnectionUri http://$URL/PowerShell/ -Authentication Kerberos) -AllowClobber
}
PS> [string]$URL = $(Get-Content $HOME\.psvariables\exchangeserver)
PS> Import-PSSession -Verbose (New-PSSession -Verbose -Name Exchange2013 -ConfigurationName Microsoft.Exchange -ConnectionUri http://$URL/PowerShell/ -Authentication Kerberos)
WARNING: The names of some imported commands from the module 'tmp_wyqpohdw.ids' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0 tmp_wyqpohdw.ids {Add-ADPermission, Add-AvailabilityAddressSpace, Add-ContentFilterPhrase, Add-DatabaseAvailabilityGroupServer...}
PS> get-mailbox test
Name Alias ServerName ProhibitSendQuota
---- ----- ---------- -----------------
test test exchange2013 Unlimited
PS> Connect-Exchange
WARNING: The names of some imported commands from the module 'tmp_fan0rj3t.nzp' include unapproved verbs that might make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the Verbose parameter. For a list of approved verbs, type Get-Verb.
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0 tmp_fan0rj3t.nzp {Add-ADPermission, Add-AvailabilityAddressSpace, Add-Conte...
PS> get-mailbox test
get-mailbox : The term 'get-mailbox' 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.
At line:1 char:1
+ get-mailbox test
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (get-mailbox:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question