Jump to content

Recommended Posts

Posted

Hi All

 

i have been trying to connect to Teams Powershell with no luck, i have submitted a ticket to my csp but they havent been able to help me connect i have put the error i am seeing below. can anyone help🙌

 

 

 

PS C:\Windows\system32> #$Credential = Get-Credential

Connect-AzureAD -Credential $Credential

Import-Module MicrosoftTeams

Connect-MicrosoftTeams -Credential $Credential

$Group = Get-AzureADGroup -All $true | Where-Object {$_.DisplayName -eq "Students" } #needs to be in "" change this to your Azure group name

$Members = Get-AzureADGroupMember -ObjectId $Group.ObjectId -All $true

foreach ($Member in $Members)

{

Grant-CsUserPolicyPackage -Identity $Member.UserPrincipalName -PackageName "Education_SecondaryStudent" # Change this to Education_Teacher for your staff if you want to.

}

Connect-AzureAD : The term 'Connect-AzureAD' 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:3 char:1

+ Connect-AzureAD -Credential $Credential

+ ~~~~~~~~~~~~~~~

+ CategoryInfo : ObjectNotFound: (Connect-AzureAD:String) [], Com

mandNotFoundException

+ FullyQualifiedErrorId : CommandNotFoundException

 

Connect-MicrosoftTeams : The term 'Connect-MicrosoftTeams' 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:7 char:1

+ Connect-MicrosoftTeams -Credential $Credential

+ ~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : ObjectNotFound: (Connect-MicrosoftTeams:String)

[], CommandNotFoundException

+ FullyQualifiedErrorId : CommandNotFoundException

 

Get-AzureADGroup : The term 'Get-AzureADGroup' 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:9 char:10

+ $Group = Get-AzureADGroup -All $true | Where-Object {$_.DisplayName - ...

+ ~~~~~~~~~~~~~~~~

+ CategoryInfo : ObjectNotFound: (Get-AzureADGroup:String) [], Co

mmandNotFoundException

+ FullyQualifiedErrorId : CommandNotFoundException

 

Get-AzureADGroupMember : The term 'Get-AzureADGroupMember' 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:11 char:12

+ $Members = Get-AzureADGroupMember -ObjectId $Group.ObjectId -All $tru ...

+ ~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : ObjectNotFound: (Get-AzureADGroupMember:String)

[], CommandNotFoundException

+ FullyQualifiedErrorId : CommandNotFoundException

Posted
PS C:\Windows\system32> install-module MicrosoftTeamsPS C:\Windows\system32> Import-Module MicrosoftTeamsPS C:\Windows\system32> Connect-MicrosoftTeams -Credential $CredentialConnect-MicrosoftTeams : The term 'Connect-MicrosoftTeams' is not recognizedas the name of a cmdlet, function, script file, or operable program. Checkthe spelling of the name, or if a path was included, verify that the path iscorrect and try again.At line:1 char:1+ Connect-MicrosoftTeams -Credential $Credential+ ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Connect-MicrosoftTeams:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Posted

I prefer to use Powershell ISE as you can run lines of code at a time - aso you need to make sure you are right click and run as admin

 

install-module MicrosoftTeams -Force -Verbose

 

 

Also worth checking and trying the following

 

Get-PSRepository

 

and you should see something silimar -

 

Name InstallationPolicy SourceLocation

---- ------------------ --------------

PSGallery Untrusted https://www.powershellgallery.com/api/v2

Posted
VERBOSE: Using the provider 'PowerShellGet' for searching packages.VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='MicrosoftTeams'' for ''.VERBOSE: Total package yield:'1' for the specified package 'MicrosoftTeams'.VERBOSE: Performing the operation "Install-Module" on target "Version '1.0.6' of module 'MicrosoftTeams'".VERBOSE: The installation scope is specified to be 'AllUsers'.VERBOSE: The specified module will be installed in 'C:\Program Files\WindowsPowerShell\Modules'.VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.VERBOSE: Downloading module 'MicrosoftTeams' with version '1.0.6' from the repository'https://www.powershellgallery.com/api/v2'.VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='MicrosoftTeams'' for ''.VERBOSE: InstallPackage' - name='MicrosoftTeams',version='1.0.6',destination='C:\Users\adm\AppData\Local\Temp\62669380'VERBOSE: DownloadPackage' - name='MicrosoftTeams',version='1.0.6',destination='C:\Users\adm\AppData\Local\Temp\62669380\MicrosoftTeams\MicrosoftTeams.nupkg',uri='https://www.powershellgallery.com/api/v2/package/MicrosoftTeams/1.0.6'VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/MicrosoftTeams/1.0.6'.VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/MicrosoftTeams/1.0.6'.VERBOSE: Completed downloading 'MicrosoftTeams'.VERBOSE: Hash for package 'MicrosoftTeams' does not match hash provided from the server.VERBOSE: InstallPackageLocal' - name='MicrosoftTeams',version='1.0.6',destination='C:\Users\adm\AppData\Local\Temp\62669380'VERBOSE: Catalog file 'MicrosoftTeams.cat' is not found in the contents of the module 'MicrosoftTeams' being installed.VERBOSE: Valid authenticode signature found in the file 'MicrosoftTeams.psd1' for the module 'MicrosoftTeams'.VERBOSE: For publisher validation, current module 'MicrosoftTeams' with version '1.0.6' with publisher name'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'. Is this modulesigned by Microsoft: 'True'.VERBOSE: For publisher validation, using the previously-installed module 'MicrosoftTeams' with version '1.0.6' under'C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\1.0.6' with publisher name 'CN=Microsoft Root CertificateAuthority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'. Is this module signed by Microsoft: 'True'.VERBOSE: Authenticode issuer 'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond,S=Washington, C=US' of the new module 'MicrosoftTeams' with version '1.0.6' matches with the authenticode issuer'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US' of thepreviously-installed module 'MicrosoftTeams' with version '1.0.6'.WARNING: The version '1.0.6' of module 'MicrosoftTeams' is currently in use. Retry the operation after closing theapplications.
Posted (edited)

wondering if there is an issue with your powershell, as when I run that command on WIn10 and Server 2016 and 2019 it installs fine.

 

I'll copy the module and upload it with instructions on how to manually install the module in the morning if that ok.

Edited by mdrabble
Posted

Just read the last bit of the message you posted and it looks like the module is installed as it says the module is in use.

 

Will take a proper look in the morning as my little one has just woken up and needs feeding.

Posted

Let’s start from scratch and close any and all powershell windows.

 

Open either powershell or powershell ise as admin

 

Don’t run any scripts just yet and run the following command

 

Get-InstalledModule

 

Should return a list of all installed modules and hopefully we should see MicrosoftTeams

 

If MicrosoftTeams is listed then on another new line type in

 

Import-Module MicrosoftTeams -verbose

 

Using the -verbose switch so we can see what is happening when the command runs.

 

Hopefully you shouldn’t see any error messages.

 

If at this point all is good, then you should be able to run the powershell script to assign the team assignments.

Posted
Have you installed the AzureAD module (as it's failing on the Get-AzureADGroup cmdlets)? Install-Module AzureAD in an elevated shell, then in the script Import-Module AzureAD
Posted

Hi All

 

Thanks for you help, i have managed to get the powershell working, but the script to set the permission for the students doesnt seem to work ?

 

Has anyone applied permissions via Powershell to a group such as "Students"

 

Thanks

Posted (edited)

On the script it looks for an AD group called students as that’s what I have my students in - made it easier to apply on mass.

 

I created an AD group called students and added all student accounts to that group that way the script could apply setting to all Students in one go.

 

If your students are in a different AD group change students in the script to match your AD group.

 

Hope that makes sense.

Edited by mdrabble
Posted
Personally I would use a group like @mdrabble has said or set an ext attrib on the accounts as you provision them from your identity management system then you can ripple a get-Aduser over AD. Loading out of a file adds a step thats not required and makes it difficult to run any kind of script that checks local users against synced users. That's said those type of scripts come over time.
Posted
The reason I ask is a get-content is streaming in a file (I am assuming that the file contains a list of users?) then the next line uses that var in -Identity apart from the fact PS is saying don't pass me a Null value even if it ain't null that's going to throw an exception. Would need to use some kind of loop...
Posted

$user_ids.foreach({PS COMMAND -Identity $_ -OTHERPARAMS})

 

The foreach method is by far the best way to invoke looping in PS since PS V4 due to the work that the .NET team have done under the hood.

Posted

@Uber22 - Here is my original script

 


$cred = Get-Credential "[email protected]"
Connect-AzureAD -Credential $cred
Connect-MicrosoftTeams -Credential $cred

#Change Students in Year 7 to your selected AD Group
$group = Get-AzureADGroup -SearchString "Students in Year 7"

$members = Get-AzureADGroupMember -ObjectId $group.ObjectId -All $true | Where-Object {$_.ObjectType -eq "User"}

#Name : Education_Teacher
#Description : This is an Education_Teacher package
#
#Name : Education_SecondaryStudent
#Description : This is an Education_SecondaryStudent package

#Change the PackageName to your chosen package
$members | ForEach-Object {
Write-host Assigning Team Policy to: $_.UserPrincipalName
Grant-CsUserPolicyPackage -PackageName Education_SecondaryStudent -Identity $_.UserPrincipalName
}
[/Code]

 

One thing I forgot to mention is that we use AzureConnect - so when we create AD Groups etc, they then get Sync'd into Azure.

 

I use groups for my students - such as Students in Year 7 for all students in Year 7, etc.....

 

So providing your students are in a group, all you need to do is change $group to match your chosen AD Group.

 

Hope that all makes sense.......

 

If anyone can see if there is an easier way to do the loops than by all means let me know :-)

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...