I'm trying to connect from my PowerShell to Exchange 2007 (both are on the same computer).
What am I missing?
My code:
Set-ExecutionPolicy RemoteSigned
$cred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri
https://localhost/powershell/ -Credential $cred -Authentication Basic –AllowRedirection
Import-PSSession $Session
The error I get:
[localhost] Connecting to remote server failed with the following error message : The server certificate on the destination computer (localhost:443) has the following errors:
The SSL certificate is expired. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionOpenFailed
Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Supply a non-null argument and try the command again.
At line:3 char:17
+ Import-PSSession <<<< $Session
+ CategoryInfo : InvalidData: (:) [Import-PSSession], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportPSSessionCommand
Remoting does not work with Exchange 2007. Never has.
Related
I am trying to connect O365 exchange / Exchange Online from powershell, I am using this link as guide.
however after running this powershell command
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
I am getting below error
This is error message
New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following
error message :
[ClientAccessServer=SG2PR01CA0093,BackEndServer=,RequestId=2498a60b-034b-40d1-9e57-3e04fdae8d5f,TimeStamp=4/16/2019
9:48:00 AM] [FailureCategory=Cafe-HttpProxyException] Failed to resolve tenant name from SMTP address
'anna007#nitin.onmicorosft.com'. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:12
+ $Session = New-PSSession -ConfigurationName Microsoft.Exchange -Conne ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
gTransportException
+ FullyQualifiedErrorId : -2144108477,PSSessionOpenFailed
It was username / password issue, I was copy-pasting the username and password and while copy-pasting it was taking space in password.
This can be caused by a lack of an Exchange subscription
I'm trying to connect the Connect-MsolService from UAT enviornemnt which as Proxy configuration. We have set the proxy using netsh winhttp. My proxy has http://myproxy:8080 the same configured in IE as well. We able to access the internet. But when I using powerhshell to connect-MsolService getting the below error
I set the proxy before calling the command. I used proxy accessType and passed to Session Option. Nothing worked.
$credential = get-credential "idms#mycompany.onmicrosoft.com"
$sessionoption = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell-liveid -Credential $LiveCred -Authentication Basic -AllowRedirection
It should connect and query the data. But getting error
Connect-MsolService : An error occurred while receiving the HTTP response to https://provisioningapi.microsoftonline.com/provisioningwebservice.svc. This
could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server
(possibly due to the service shutting down). See server logs for more details.
At line:1 char:1
+ Connect-MsolService –Credential $LiveCred -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Connect-MsolService], CommunicationException
+ FullyQualifiedErrorId : System.ServiceModel.CommunicationException,Microsoft.Online.Administration.Automation.ConnectMsolService
Connect-MsolService : Exception of type 'Microsoft.Online.Administration.Automation.MicrosoftOnlineException' was thrown.
At line:1 char:1
+ Connect-MsolService –Credential $LiveCred -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Connect-MsolService], MicrosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.MicrosoftOnlineException,Microsoft.Online.Administration.Automation.ConnectMsolService
I am trying to establish a PowerShell session to run several Exchange commands on an Exchange server on the localhost. This is not a constant issue, script is running successfully for sometime, but most of the time it is throwing following error:
New-PSSession : [Exchange-server-name] Connecting to remote server Exchange-server-name failed with the following error message : Access is denied. For more
information, see the about_Remote_Troubleshooting Help topic.
At line:9 char:15
+ $newsession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri ...
+
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : AccessDenied,PSSessionOpenFailed
Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Supply a non-null argument and try the command again.
At line:10 char:27
+ import-PSSession -session $newsession -AllowClobber
Following is my PSSession command:
$newsession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://Exchange-server-name/PowerShell/ -Authentication Kerberos -Credential $Credential
Hi I want to login into my remote server using power shell . I wrote code for this but I am getting error .
CODE
$cred = get-credential - Prompts for username and password
Enter-PSSession -ComputerName servername -Credential $cred
ERROR
Get-Credential : A positional parameter cannot be found that accepts
argument 'Prompts'.At C:\documents\Untitled8.ps1:1 char:9
+ $cred = get-credential - Prompts for username and password
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Credential], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetCredentialCommand
Enter-PSSession : Connecting to remote server XXXXX failed with the
following error message : Access is denied. For more information, see
the about_Remote_Troubleshooting Help topic.At
C:\documents\Untitled8.ps1:5 char:1
+ Enter-PSSession -ComputerName servername -Credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (servername:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
Any clue regarding this will help....
Get-Credential : A positional parameter cannot be found that accepts argument 'Prompts'
Anybody have any clue how to login into remote server in power shell using servername..any clue any link regarding this will be helpful
The problem is that there it can´t find a positional parameter, where "Prompts" is accepted. If you look at the help file for Get-credential you will see that the -Credential paramenter is positional, meaning you dont need to type it.
Try with this
$cred = get-credential -Message "Prompts for username and password"
Enter-PSSession -ComputerName servername -Credential $cred
Some reading about positional parameters
https://itknowledgeexchange.techtarget.com/powershell/positional-parameters/
I have a Sharepoint farm setup and I'm connecting to one of my application/search servers from a Windows 7 machine in the domain using remote powershell. Both the client and application servers have powershell 2 with the execution policy set to unrestricted and psremoting enabled. Additionally, i'm running the cmdlets as a domain administrator account.
I can create a session to the remote server using the following cmdlets:
$Session = New-PSSession -ConfigurationName "Microsoft.PowerShell" -ConnectionUri "http://app01-spl1:5985/wsman/" -Authentication "Kerberos"
Import-PSSession $Session -AllowClobber
However, When I Import the session I get the following eror:
Import-PSSession : Proxy creation has been skipped for '%' command, because PowerShell couldn't verify its name as safe.
At line:1 char:17
+ Import-PSSession <<<< $Session -AllowClobber
+ CategoryInfo : InvalidData: (:) [Import-PSSession], InvalidOperationException
+ FullyQualifiedErrorId : ErrorSkippedUnsafeCommandName,Microsoft.PowerShell.Commands.ImportPSSessionCommand
Import-PSSession : Proxy creation has been skipped for '?' command, because PowerShell couldn't verify its name as safe.
At line:1 char:17
+ Import-PSSession <<<< $Session -AllowClobber
+ CategoryInfo : InvalidData: (:) [Import-PSSession], InvalidOperationException
+ FullyQualifiedErrorId : ErrorSkippedUnsafeCommandName,Microsoft.PowerShell.Commands.ImportPSSessionCommand
Import-PSSession : Could not resolve remote alias 'ise'.
At line:1 char:17
+ Import-PSSession <<<< $Session -AllowClobber
+ CategoryInfo : OperationTimeout: (:) [Import-PSSession], ArgumentException
+ FullyQualifiedErrorId : ErrorCouldntResolveAlias,Microsoft.PowerShell.Commands.ImportPSSessionCommand
Can anyone help solve this error?
I resolved this by simply entering the remote session instead of importing it. I was then able to add the SharePoint snap-in installed on the remote machine and run my script.
$Session = New-PSSession -ConfigurationName "Microsoft.PowerShell" -ConnectionUri "http://app01-spl1:5985/wsman/" -Authentication "Kerberos"
Enter-PSSession $Session
Add-PSSnapin Microsoft.SharePoint.PowerShell
<Cmdlets or script goes here>
Exit-PSSession
Remove-PSSession -ID $Session.ID
[GC]::Collect()
Another option is to use Invoke-Command cmdlet with the ScriptBlock parameter like so.
$Session = New-PSSession -ConfigurationName Microsoft.PowerShell -ConnectionUri "http://app01-spl1:5985/wsman/" -Authentication Kerberos
Invoke-Command -Session $Session -ScriptBlock { Add-PSSnapin Microsoft.SharePoint.PowerShell }
Invoke-Command -Session $Session -ScriptBlock { <Your cmdlet here.> }
Remove-PSSession -ID $Session.ID
[GC]::Collect()
The error is that you are trying to import the entire set of commands from your remote server. Not quite sure why you are allowing clobber.
Personally, I'd just import the relevant SHarePoint module(s) rather than all of the remote workspace.
Does the import work??