Edu-IT Posted March 20, 2014 Posted March 20, 2014 I thought the GB was just to set the users location so they did not get the prompt on first login and nothing to do with the data centre (since educational accounts get the European ones for us)Think you're spot on. That command didn't allow me to see what was currently set. Did it work for you?
Boredguy Posted March 20, 2014 Posted March 20, 2014 It works when we run "Set-MsolUser -UserPrincipalName $user.UserPrincipalName -UsageLocation GB" in our activation script and assigning licenses. Can't say I've see the location selection screen since running it unless I have manually created a user in the 365 web interface and not via DirSync.
chazzy2501 Posted March 20, 2014 Posted March 20, 2014 (edited) BeaminsterSch:STANDARDWOFFPACK_STUDENT -DisabledPlans MCOSTANDARD, SHAREPOINTWAC_EDU, SHAREPOINTSTANDARD_EDU This seems to be a popular option will this give my users office web apps and onedrive? I though OneDrive required sharepoint? Where-Object {$_.Office -eq "Pupil" } I'm assuming this means department? My pupils are in a department of Pupil. #Set the license options for Office 365, which in this case is just Exchange access $LicOptions = New-MsolLicenseOptions -AccountSkuId BeaminsterSch:STANDARDWOFFPACK_STUDENT -DisabledPlans MCOSTANDARD, SHAREPOINTWAC_EDU, SHAREPOINTSTANDARD_EDU #Search for users that have no licences as they have just been syncronised and store into array where username begins STU $users = Get-MsolUser -UnlicensedUsersOnly -Synchronized -MaxResults Unlimited | Where-Object {$_.Office -eq "Pupil" } #If we have no users then we can exit out of the script if (!($users)) {exit;} #For each user we found, we will loop thought them and apply settings Write-Host "Set Licence" foreach ($user in $users) { #Displays on screen the user we are updaing purely for debugging purpose Write-Host $user.UserPrincipalName #Set the Office 365 license for the user based on the value selected above. This is purely for students Set-MsolUserLicense -UserPrincipalName $user.UserPrincipalName -AddLicenses "tenancy:STANDARDWOFFPACK_STUDENT" -LicenseOptions $LicOptions After I apply the above how to I apply proplus (as the users will now be licenced) Could I filter by security group instead? (I have 2 from ActiveDir "students" and "staff") I'm new to power script It seems odd. The above looks for unlicensed users then does something to the student a2 plan, then disables options in that package then assigns the plan.. is that the gist of it? Edited March 20, 2014 by chazzy2501
sonofsanta Posted March 20, 2014 Posted March 20, 2014 I don't disable any plans when I assign the licences: # based on http://community.office365.com/en-us/forums/148/t/17328.aspx Connect-MSOLService -Credential $adminCredential # ask admin which type of account we are adding from migration.csv, checking it's a valid choice while ($userType -ne 1 -and $usertype -ne 2) { $userType = Read-Host "type 1 for STUDENTS; type 2 for STAFF" } # set $AccountSkuID appropriately if ($userType -eq 1) { $AccountSkuId = "BeaminsterSch:STANDARDWOFFPACK_STUDENT" } elseif ($userType -eq 2) { $AccountSkuId = "BeaminsterSch:STANDARDWOFFPACK_FACULTY" } Write-Host $accountSkuID # setting other options $LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId # import CSV $Users = Import-Csv D:\Office365\migration.csv # for each user, set location & assign licence $Users | ForEach-Object { Set-MsolUser -UserPrincipalName $_.EmailAddress -UsageLocation GB Set-MsolUserLicense -UserPrincipalName $_.EmailAddress -AddLicenses $AccountSkuId -LicenseOptions $LicenseOptions Write-Host "Licence set for user" $_.EmailAddress -f green if ($userType -eq 1) { Set-MsolUserLicense -UserPrincipalName $_.EmailAddress -AddLicenses "BeaminsterSch:OFFICESUBSCRIPTION_STUDENT" Write-Host $_.EmailAddress "granted Office licence" -f yellow } } That script asks who you're assigning licences to (1 for students, 2 for staff), reads in a list of usernames from a CSV file with a single column headed EmailAddress (D:\Office365\migration.csv - change that to whatever suits your purposes) then assigns the relevant licence. If it's students being licensed, it then also adds the OFFICESUBSCRIPTION_STUDENT to the user - which is what gives them the Pro Plus install. That doesn't scan for unlicensed uses on a scheduled task, because that (or a variant of it) is run whenever we set up a new student as part of the procedure. Works for me /shrug 1
Boredguy Posted March 20, 2014 Posted March 20, 2014 For Proplus, you can add that Set-MsolUserLicense just under the existing one, which is what we do for new students For existing users that we rolled ProPlus to, we just adjusted the same search but without the -UnlicensedUsersOnly flag
chazzy2501 Posted March 20, 2014 Posted March 20, 2014 I could have done it by hand 3 times over by now... So that what I'll do
chazzy2501 Posted March 20, 2014 Posted March 20, 2014 @sonofsanta I can't get this to work? it just outputs "type 1 for students or staff" every other line of the script?
sonofsanta Posted March 20, 2014 Posted March 20, 2014 @sonofsanta I can't get this to work? it just outputs "type 1 for students or staff" every other line of the script? Should only do that if you're giving it something other than 1 or 2 for the answer, as per the while loop. Try adding Write-Host "userType was " $userType -f red in the while loop, after the Read-Host line, see if it's outputting what you input.
chazzy2501 Posted March 20, 2014 Posted March 20, 2014 I'm copying your script and right clicking and pasting into the ps window. is their another way?
chazzy2501 Posted March 20, 2014 Posted March 20, 2014 (edited) hummm, spotted an error with my csv and re did it... it's zipping away with yellow green and mostly red stuff EDIT: it's stopped not complete: The term 'Set-MsolUserLicense' is not recognized as the name of a cmdlet, funct ion, 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:8 char:28 + Set-MsolUserLicense <<<< -UserPrincipalName $_.EmailAddress -AddLice nses + CategoryInfo : ObjectNotFound: (Set-MsolUserLicense:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException BeaminsterSch:OFFICESUBSCRIPTION_STUDENT [email protected] granted Office licence looking at the last user it says licence granted but it hasn't. Edited March 20, 2014 by chazzy2501
sonofsanta Posted March 20, 2014 Posted March 20, 2014 Save it into a blank text document, save it with a .ps1 extension, then open PowerShell, cd to the correct directory and run it with .\scriptName.ps1 - easiest way of running it (whilst being able to edit it). Not sure why it's complaining about Set-MsolUserLicense not being recognized - it bloomin' well is a command. Have you installed the Windows Azure Active Directory Module for Windows Powershell?
chazzy2501 Posted March 20, 2014 Posted March 20, 2014 I consider myself moderately intelligent and all I have to do is modify a script! 3 hours of pi55ing around has gotten me bu33er all. Now is it possible that I have an old or wrong version of something? because I'm pasting in commands and something won't work. (named parameter not found and invalid arguments) Could someone write a script for me "a2 plan students" & "office pro plus" for all my pupils in the department "pupil" and set them to GB location just in case. This may need to override existing licensing options and they may or may not be licenced. my sdku thingy is "BeaminsterSch" I'm updating my server tonight in case I'm missing a patch>?
EduTech Posted March 20, 2014 Posted March 20, 2014 Hi, If you are finding that the above cmdlets are not available for you to use, then this is most likely because you have an out-dated version of the Windows Azure Active Directory PowerShell Module. I would advise you to review the following article: Manage Windows Azure AD using Windows PowerShell Download the latest version of the PowerShell module based on the architecture of your device. If you need any further help let me know. James.
chazzy2501 Posted March 20, 2014 Posted March 20, 2014 That is the exact link where I installed the module this morning. (the link was purple :0) I've just spotted the run as admin in the startup (I've been using the desktop shortcut) most things although not working are now not complaining of unknown cmdlts! This Fing sucks... Hours wasted because of a useless need to run as admin... starting over.. .
chazzy2501 Posted March 20, 2014 Posted March 20, 2014 That is the exact link where I installed the module this morning. (the link was purple :0) I've just spotted the run as admin in the startup (I've been using the desktop shortcut) most things although not working are now not complaining of unknown cmdlts! This Fing sucks... Hours wasted because of a useless need to run as admin... starting over.. .
FN-GM Posted March 20, 2014 Posted March 20, 2014 (edited) I've just been reading up, and apparently the data centre is decided when you sign up, not because of this command? Got a link somewhere that says different. Apparently its like that for companies who are global so they can use the data center closest to the user. Checked the link, its dead, must be duff information! Edited March 20, 2014 by FN-GM
EduTech Posted March 20, 2014 Posted March 20, 2014 That is the exact link where I installed the module this morning. (the link was purple :0) I've just spotted the run as admin in the startup (I've been using the desktop shortcut) most things although not working are now not complaining of unknown cmdlts! This Fing sucks... Hours wasted because of a useless need to run as admin... starting over.. . The symptoms your have been explaining would be caused if you are using an out of date module or if the module hasn't been imported into the powershell session. so please be mindful this is the case before running such commands. It's not hours wasted :-) it's all good learning! James.
Edu-IT Posted March 21, 2014 Posted March 21, 2014 While we're talking Powershell. Does anyone know how I can bulk add a an SMTP address to each user that is the same as the first part of their current SMTP address, but with a different latter part? For example [email protected] is their current one, but I want to add [email protected] and set that as their primary. And do the same for each user.
sonofsanta Posted March 21, 2014 Posted March 21, 2014 (edited) While we're talking Powershell. Does anyone know how I can bulk add a an SMTP address to each user that is the same as the first part of their current SMTP address, but with a different latter part? For example [email protected] is their current one, but I want to add [email protected] and set that as their primary. And do the same for each user. In an Active Directory powershell window (not Azure, local AD), based on looping through a CSV called changeEmail.csv saved in the same folder as this .ps1 script with the header EmailAddress and Username: Import-Csv .\changeEmail.csv | foreach-object { $coUkEmail = $_.EmailAddress.Replace("google.com", "google.co.uk") Set-ADUser -Identity $_.Username -EmailAddress $coUkEmail Get-ADUser $Username | Set-ADUser -Add @{proxyAddresses=$EmailAddress} -PassThru Write-Host "`n============================================`n" -ForegroundColor Green } That uses Replace to create the new email based on the old, sets the primary address to the new, and adds the old as a proxy address (which is what Office 365 uses for alternate addresses - don't know about Google apps if that's what you're using). Not actually tested that as it's based on combining & stripping down parts from two scripts, one used to add the @ tenancy.onmicrosoft.com address as well as an @ school.org address, the other for renaming a user and keeping all their old addresses. You should be able to create the CSV using PowerShell to dump AD details into a file, though it might take some tidying up. And yes, I do use CSVs for all my PowerShell, because I am a one trick pony and can't work out the better ways of doing it if you wanted to do it all at once there should be a way of just moving through all the AD objects in a particular tree - someone smarter may be able to tell you. Edited March 21, 2014 by sonofsanta
Boredguy Posted March 21, 2014 Posted March 21, 2014 (edited) You can do it easily without scripting via the AD Users and Computer interface Select your users -> Properties Tick the e-mail box then enter the value %username%@google.co.uk Hit Ok and it's done Note: it will replace the old one, otherwise you will need to PS it to use the proxyAddress for aliases Edited March 21, 2014 by Boredguy
Edu-IT Posted March 21, 2014 Posted March 21, 2014 Due to our setup, I was hoping there was a way to do it directly on Office365 through Powershell rather than our own AD. I want to create the new primary SMTP address on Office 365. I am a little confused about what you've posted will do in that regard?
sonofsanta Posted March 21, 2014 Posted March 21, 2014 Set-MsolUser (in Windows Azure AD) has the -AlternateEmailAddress flag, you could probably do something with that (and using the .replace() to work out what you're adding). Can't see anything for changing the primary email there - perhaps you just need to change -UserPrincipalName to do it? You'd need to make sure your onsite AD matches, though. That script above read in username and email address for a list of users, worked out what the new email address would be based on a domain swap, set that as the primary email address and added the original email (as read from the CSV) as a proxyAddress, which is the AD attribute containing all the alternate email addresses for a user. Runs on local AD because that's how I do it here and as I didn't know you needed it to work specifically on Office 365. You should be able to adapt it using Set-MsolUser. You might have to do it by connecting to the remote Exchange, acually - use Set-Mailbox -EmailAddresses, e.g. Set-Mailbox [email protected] -EmailAddresses SMTP:[email protected],[email protected],[email protected],[email protected] Could build up the list of email addresses with the .replace as above.
Edu-IT Posted March 21, 2014 Posted March 21, 2014 @edu-tech Any advice on changing the primary SMTP?
sonofsanta Posted March 21, 2014 Posted March 21, 2014 @edu-tech Any advice on changing the primary SMTP? FWIW, that Set-Mailbox command sets the first email in the list as primary (e.g. [email protected]) and the others as alternates. You can run Exchange commands on Office 365 directly by opening Powershell and running Set-ExecutionPolicy RemoteSigned $LiveCred = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection Import-PSSession $Session
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now