Yes, using ARM, not Bicep, I know, it’s bad!
Ran into a whole bunch of constrains and issue trying to assign an array of principals vs roles on keyvault using the RBAC access method, so sharing my working solution here as I couldn’t find a single good example on google:
"name": "[concat(variables('vaultName'),'/Microsoft.Authorization/',guid(concat(variables('vaultName'), parameters('accessPolicies')[copyIndex('rbac-access-policy-loop')].objectId, parameters('accessPolicies')[copyIndex('rbac-access-policy-loop')].roleId)))]",
"scope": "[resourceId('Microsoft.KeyVault/vaults', variables('vaultName'))]",
An example param would then look like this:
If you know how to clear the ODBC Driver 17’s token cache, please comment 🙂
Ran into the following error today and putting it here for searches as literally nothing came up:
Run-time error '-2147467259 (80004005)':
[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]User option must be specified, if Authentication option is 'ActiveDirectoryInteractive'.
This was through an excel Macro, connecting to an Azure PaaS database. All other users were just getting prompted, but one kept having this issue.
We managed to ‘solve’ the issue by going into the macro properties and adding User IDfirstname.lastname@example.org to the connection string where email@example.com was the user’s actual UPN.
When a user leaves the organization, their Onedrive folders/files remain until either the user is permanently deleted or the retention policy covering their data expires.
Many organizations have set up a
retention policy in Office 365 to retain data in Onedrive for several years, sometimes even indefinitely.
Few know, that as long as you retain a user’s onedrive, the files and folders that were shared, by default,
remain shared and accessible by those they were shared with, including externals.
This is often undesirable, and can easily be remediated by running a very simple
unshare-orphanedOnedriveForBusinessSites.ps1 PowerShell function I’m hereby sharing with you 🙂
Above function detects all Onedrive Sites that no longer have an active associated user, and disables any sharing links on them.
The actual line that unshares an individual site could also be used directly if you have an automatic offboarding process.
Using MEM (Intune) we can automatically deploy VPN profiles to our users’ managed devices directly.
The set of parameters that can be configured in MEM is extremely limited compared to what actually ends up on the rasphone.pbk file (VPN Profile) on a Windows client.
Example of a .pbk file for an Azure P2S VPN connection with Conditional Access/cert based SSO:
PreferredDevice=WAN Miniport (IKEv2)
Device=WAN Miniport (IKEv2)
Modifying VPN Profile settings
To allow admins further customization of these settings, I’ve written a
Proactive Remediation script that can customize any VPN profile property to any value you specify.
In our case, we used it to set IpInterfaceMetric, which defaults to 0, causing ambiguously routed traffic to never prefer the VPN connection (since this is a split tunnel connection). Setting it to 1 resolved our DNS/routing issues to certain private endpoints in our Azure environment.
Code / git link:
As with cleaning up
inactive guest users, inactive devices also pose several issues for organizations.
recommends cleaning up stale devices after 90 days, but does not provide a service option or automation to do so.
Therefore, here’s another runbook you may run to just report on your inactive devices, or to automatically (and optionally periodically) clean up inactive devices in your environment when the removeInactiveDevices switch is supplied.
When run locally, interactive sign in is required. When running as a runbook in Azure automation, the Managed Identity of the automation account is leveraged. This requires you to
set Device.ReadWrite.All or Device.Read.All permissions depending on if you want to script to do the cleanup as well. If doing cleanup, also add the managed identity to the cloud device administrator (Azure AD) role.
Autopilot / on premises devices
Note that the script will log an error (and not attempt to delete the device) when a device is an autopilot record (not a real device) or when the device is synced from an on-premises active directory.
Disable vs Delete
The runbook also has a disable option, in which it will first disable a device and wait a configurable ($disableDurationInDays) period of time before actually deleting a device.
Download get-AzureADInactiveDevices.ps1 from Gitlab
As always, the script is provided as-is and should be reviewed and then used at your own risk.