PowerShell parameter question

I'm not sure not sure what the correct syntax for -ConnectionURi should be

s=New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://contoso/powershell -Authentication Kerberos

Should the Uri be my cas server or my exchange server address? And would it be the FQDN name?
iamuserAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vasil Michev (MVP)Commented:
What are you trying to achieve? Loading the Exchange cmdlets in 'regular' PowerShell is not supported (for on-prem servers that is), use the EMS instead.
iamuserAuthor Commented:
I am running a Powershell script that will create bulk AD and mail accounts for new hires.
iamuserAuthor Commented:
on the on premise Exchange server
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

iamuserAuthor Commented:
this is the script, i did not create this, this was published on line

#############################################################################
# New-UserAD and Email
# Create email and AD Account for new Users in Contoso.com
#
#  
#  
#
# ============================================================================
 
 
$date = Get-Date
#Set up Log files for output
$ErrorLog = "C:\Errorlog.txt"
$SuccessLog = "C:\Successlog.txt"
Add-Content $SuccessLog "-----------------------------------------------------------------"
Add-Content $SuccessLog $date
Add-Content $SuccessLog "-----------------------------------------------------------------"
Add-Content $ErrorLog "-------------------------------------------------------------------"
Add-Content $ErrorLog $date
Add-Content $ErrorLog "-------------------------------------------------------------------"
 
## Create Session with Exchange 2010 change your URI address  
$s=New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://contoso/powershell -Authentication Kerberos
 
Import-PSSession -Session $s
## Add AD Cmdlets
Import-Module ActiveDirectory
#Import CSV  
 
$csv = @()  
$csv = Import-Csv -Delimiter "," -Path "C:\ADuser.csv"
#Get Domain Base  
$searchbase = Get-ADDomain | ForEach {  $_.DistinguishedName }  
 
#Loop through all items in the CSV  
ForEach ($user In $csv)  
{  
 
    ## change your OU with your own OU
    $OU = "OU=New Users,OU=Users,OU=employee,DC=Contoso,DC=com"  
    $Password = "Abc123+"
    $title= $user.'New Post title'
    $lastname= ($user.'Last name'.Substring(0,1).toupper() + $User.'Last name'.Substring(1).tolower())
    $Detailedname = $User.'First name' + " " + $lastname  
    $UserFirstname = $User.'First name'  
    $SAM =  $User.'First name' + "." +  $lastname
    $UPN= $UserFirstname + "." +  $lastname + "@contoso.com"
    $ID= $user.ID
    $Displayname= "$Detailedname" + "  " + "-" + "  " + "$title"
    $Company= "Contoso"
    $Dis= "Contoso User"
    $group= "All Users","All Contoso Users"
    $homedrive= "\\nas1\home\%username%"
     
 
  #Check if the User exists  
  $NameID = $user.ID
$User = Get-ADUser -LDAPFilter "(EmployeeID=$NameID)"
If ($User -eq $Null)  
 
    {  
      #Create the User if it doesn't exist  
       
       
      $create = New-ADUser -Name $Detailedname -SamAccountName $SAM -UserPrincipalName $UPN  -DisplayName $Displayname -GivenName $UserFirstname -Surname $lastname -AccountPassword (ConvertTo-SecureString $Password -AsPlainText -Force) -Enabled $true -Path $OU -EmployeeID $ID -Title $title -Description $Dis -Company $Company -HomeDrive Z: -HomeDirectory $homedrive -ChangePasswordAtLogon $true  
       
      Write-Host "AD Account $Detailedname created!"  
       
      add-content $SuccessLog  "User $SAM created Sucessfully."
 
   
 
      ## Adding User to Group
      Add-ADPrincipalGroupMembership -Identity $SAM -MemberOf $group
       
      Write-Host " Added to Groups Needed"  
       
      add-content $SuccessLog  "AD User $SAM Added to groups Sucessfully."
      Write-Host -ForegroundColor Green $SAM
 
      ## Creating Mailbox on EX2010
     Enable-Mailbox -Identity $SAM -Alias $SAM
 
 
 #Creating a Mail object
$outlook = new-object -ComObject Outlook.Application
 
## Create new mail
$mail = $outlook.CreateItem(0)
 
#Email structure  
 
$subject = "New User Information " 
$mail.Recipients.Add("admin.it@contoso.com")
$mail.subject = $subject
$mail.body = ("Hello All," + "`r`n" + "`r`n" + "New User Information" + "`r`n" + "First Name :" + "  " + $UserFirstname + "`r`n" + "Last Name :" + "  " + $lastname +"`r`n" + "Contoso ID# :" + "  " + $ID + "`r`n" + "Position :" + " " + $title + "`r`n" + "AD Account Created" + "`r`n" + "Thank you" + "`r`n" + " Rahmatullah Fedayizada" )  
#Sending email  
$mail.Send()
 
 
Write-Host "Email sent to Admin.it"
     
Add-Content -Path $SuccessLog -Value "Email has been sent to Admin.it " 
 
Add-Content $SuccessLog "-------------------------------------------------------------------"
## Dis Account###
 
Disable-ADAccount -Identity $SAM
 
}
Else
 
      {add-content $ErrorLog " User Already exist : $Detailedname"
       
      Add-Content $ErrorLog "-------------------------------------------------------------------"
   
       
      }
       
 
 }
Vasil Michev (MVP)Commented:
Oh I was actually thinking about loading the snap-in.  Creating a new PS session is certainly supported. The URI you need to use is the FQDN of the CAS server. For example: http://casXX.domain.com/powershell/

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
iamuserAuthor Commented:
just what i needed
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Office 365

From novice to tech pro — start learning today.