Enabling Exchange Mailbox for Exisiting User- Script without administrator credentials

Sathishkumar Singh 486 Reputation points
2022-07-11T06:31:01.763+00:00

Hello All

i am having script Automatic AD User account creation and Default group will be added to the user.
Here i want to archive exchange mailbox to be enable .
But in my script when i run from Domain controller or Windows 11 Machine. i have to be use to login after only mailbox will be able to create.
i.e:-

Set-ExecutionPolicy RemoteSigned

$UserCredential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://gvadc-ex-srv-01/PowerShell/ -Authentication Kerberos -Credential $UserCredentia

Import-PSSession $Session -DisableNameChecking

How to avoid this above process, without providing Credential , after use creation completed. mailbox to be enable?
without any user input, my exiting script it should completed.

Please advise

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,787 questions
{count} votes

1 answer

Sort by: Most helpful
  1. KyleXu-MSFT 26,291 Reputation points
    2022-07-12T01:26:56.78+00:00

    @Sathishkumar Singh

    If you want run Exchange command without credential, you need to run it on Exchange server. You can import module in PowerShell on Exchange server, then you will could run Exchange command(Exchange 2019 isn't supported):

    Exchange 2010      
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010;        
      
    Exchange 2013 & 2016      
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn;  
    

    If you need to run it from another computer, you will need to use credential, you could try with command below:

    $User = "******@domain.com"  
    $PassWord = ConvertTo-SecureString -String "Password" -AsPlainText -Force  
    $UserCredential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $User, $PassWord  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.