I’ve been using Azure Runbooks for a long time now, but when you want to ‘really’ use them in an enterprise environment, they simply do not suffice. Vote for this suggestion if you feel same:
One of my customers is doing a full cloud-only pilot of Windows 10, Mobile (MDM) managed through Intune to leverage a least-infrastructure solution worldwide.
They’re using Azure AD, but opted out of Onedrive for Business and are using Box Drive instead.
To encourage their users to actually save data to Box instead of Onedrive or locally, I wrote a little Powershell script (since Intune native PS script deployment isn’t live yet). This script checks if Box has been configured, if not it throws a little popup to the user. If it has, it redirects My Documents, and copies any existing content from it to Box.
I used Advanced Installer to wrap this in an MSI for easy deployment through Intune, and would like to share this with you 🙂
ZIP download: configureBoxRedirection_v1.02.zip
- ps1 file which does the actual work
- vbs wrapper to run it silently (hidden windows)
- .aip file (advanced installer)
- .msi file (to roll out with Intune or other tools)
- added a caching mechanism to force Box Drive to locally cache files (normally Box only does this when they are opened)
- added a caching filter to prevent caching of files above 25MB to reduce initial bandwidth overhead
- added a 5 minute loop / wait cycle to allow box to initialize, as the script may otherwise run before Box can initialize
This post describes how you can use the WIX Toolkit or any DLL file in an Azure Function, in this case to edit an MSI file on the fly. The WIX Toolkit is free, but only runs on Windows. Azure Functions run on Windows too, isn’t that nice 🙂
So, an example use case could be my OnedriveMapper MSI file, which is installed with a configuration GUID property by an admin to customize OnedriveMapper. If that GUID was already in the MSI, no such parameter would be necessary.
Using an Azure function in a download link or http request, we could insert a GUID on the fly and create personalized MSI files on demand.
I’ll leave other applications to your imagination, let’s get started!
- Download the WIX toolkit (binaries)
- Extra Microsoft.Deployment.WindowsInstaller.dll
- Add it to the function files or host it at an URL somewhere. In my example, I’m hosting it at http://www.lieben.nu/wix/wix.dll
- Add your MSI file to your function files or host it at an URL somewhere. In my example, I’m hosting it at http://www.lieben.nu/wix/OnedriveMapper.msi
- Add the following code to the Azure Function:
Natively, when connected to Office 365, Okta allows you to automatically provision users and/or groups. Additionally, Okta will assign licenses you select, and if configured, set predefined roles in Office 365. This means you have one locus of control, very nice.
Then, Exchange Online allows you to define custom roles where you can scope permissions for your users with far greater granularity compared to the default roles, Okta won’t detect or provision users into these custom roles.
As this was a business requirement for a customer, I coded up a small proof of concept you can schedule that will read membership of selected groups in Okta through the Okta API, then ensure that ONLY those members are in the matching role groups in Exchange Online.
Okta exposes a very useful API, with which I’ve been working for a while to ensure business fit for certain scenario’s that Okta and/or Office 365/Azure don’t fully support yet.
One of those scenario’s requires information about certain groups and their members. I’m narrowing the selection down to just pure Okta groups, but any groups (e.g. AD Synced) can be returned with below code by adjusting the filter in the retrieveAllOktaGroups function.
- First, you will need an Okta token to use with Powershell’s REST functions, this is the easiest part.
- Okta’s API’s are customer specific, so your $OktaAPIBaseURL parameter should be something like “https://companyname.okta.com”
- Run the retrieveAllOktaGroupsAndMembers function below with the token as a parameter
- Remember that Okta tokens expire if not used for a while
When you go cloud first, and do light MDM management of your Azure AD Joined Windows 10 devices, you will likely enable a Bitlocker policy in Intune. What you’ll quickly discover, is that your policy will not automatically enforce/enable Bitlocker on non-InstantGo capable devices.
So, I expanded upon Jan and Pieter’s script to automatically enable Bitlocker on Windows 10; it has additional error handling, local logging and it will eject removable drives prior to immediately (vs reboot) encrypting your system drive. After this is started, it will register your recovery key in AzureAD. Of course all credit for the original idea goes to Jan van Meirvenne.
Powershell source file
enableBitlockerAndRegisterInAAD_v0.04.ps1 (right click, save as)
enableBitlockerAndRegisterInAAd_v0.04.msi (right click, save as)
As Intune won’t let you deploy a Powershell script, I’ve also wrapped the script in an MSI file with Advanced Installer for you. What this will do;
- Deploy the PS1 file to the machine
- Register a scheduled task to run this PS1 file at logon each time
- Kick off the scheduled task once so a first reboot isn’t required
Advanced installer package (.aip)
enableBitlockerAndRegisterInAAD.zip (right click, save as)
- Windows 10, AzureAD Joined
- TPM chip
- User should be local admin
Version 0.56 is out, changes since v0.50:
- prevent running twice (if scheduled task hangs for some reason)
- send email notification if logfile is locked
- replace add-adgroupmember and remove-adgroupmember with set-adgroup because of a known bug in these commands
- multi-delete protection
- auto reconnect to Exchange Online when the connection times out + longer timeout
- additional filtering method for groups: extensionAttribute2
- If you want to use this instead of the displayName prefix filter, read up on how to switch
Get it here
Some Windows services can be triggered to start at certain events. These services have ‘Tigger Start’ in their startup name behind whatever you configured (like Manual).
Powershell does not have a native method to register the type of event that triggers such a service, C++ and C# do…..and Powershell can natively run C#.
To trigger a service, you’ll need its guid first:
run sc triggerinfo <SERVICENAME>
This will give you a GUID, for example for the WebClient service:
You can then use this GUID in the following script to trigger your service from Powershell 🙂 Continue reading How to start a “Trigger Start” windows service with Powershell without elevation / admin rights
Are you using aadconnect, but want your users to be able to update your Office 365 distribution lists directly in OWA (Outlook Web Access)? And still keep them in sync with your Active Directory?
Then stay tuned 😉
Version 0.9 of O365Migrator is now available as a free download.
What was changed?
- Differential transfer: upload only changed/new files. (does not process renames, moves and deletes yet!)
- Subfolder targeting: upload to a specific subfolder instead of the root if specified
- Better library name detection when admin and user have different language settings
You can find the new version here.