Jump to content

Recommended Posts

Posted

I am tying to create Dynamic Distribution groups for our Students and Staff.

 

The way our accounts have been provisioned (RM Unify) is that the distinguishing field is Job Title.

 

I have started testing with the students group but I am getting no joy. Here is the script I am trying to use:

 

New-DynamicDistributionGroup -Name "All Pupils Test" -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (Title –eq 'Student')}

 

Following instructions from: Manage Distribution Groups by using PowerShell - o365info.com

 

However I get the following error when run:

 

error.jpg

 

Can anyone see where I am going wrong?

Posted
New-DynamicDistributionGroup -Name "Pupil Test" -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (Title -eq 'Student')} created a new DDG happily for me
  • Thanks 1
Posted

I am really stuck here then. The only thing I find strange when I am trying this is my connection method.

 

At the start of most of my scripts I use:

 

Connect-MsolService

 

However when using this for this command I get a error saying the cmdlets are not found. Instead if I use the following:

 

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

 

It loads the cmdlets and allows me to run. Could this be causing my problem?

Posted

We use the following connection strings for our scripts as most of them are automated

Import-Module MSOnline
$password = "Blahhblahblah"
$username = "[email protected]"
$securepass = ConvertTo-SecureString -AsPlainText -String $password -Force

$LiveCred = New-Object System.Management.Automation.PSCredential -argumentlist $username,$securepass

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
Connect-MsolService -Credential $LiveCred

 

If is does not know what cmdlets to install it will get upset, but we have found that the above, while overkill at times, works nicely and means we can also just load a single ps1 file to connect to 365 via Powershell ISE, then carry on with the rest of the commands manually

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...