The OneDrive Known Folder Move feature has been around for a couple of years. Basically, this allows you to redirect common (well-known) folders from your PC to OneDrive so that anything created in Documents, Pictures, and the desktop is automatically saved in your OneDrive for Business account. Generally, everything works well, and I have been very happy.
Except until the time came to update the Azure Active Directory preview module from 184.108.40.206 to 220.127.116.11.
Problems Updating PowerShell Module
I followed my normal routine of upgrading the module from the PowerShell Gallery, but things didn’t work. And no combination of removing and reinstalling modules worked either, despite setting a required version for the Install-Module cmdlet. Each time I started PowerShell and connected to Azure Active Directory, version 18.104.22.168 was used.
Eventually I discovered that the 22.214.171.124 files were installed in OneDrive by examining the module properties:
Get-Module -Name AzureADPreview | fl Name : AzureADPreview Path : C:\Redmond\OneDrive – Office365ITPros\Documents\WindowsPowerShell\Modules\AzureADPreview\126.96.36.199\ Microsoft.Open.AzureAD16.Graph.PowerShell.dll
My speculation is that PowerShell installed the 188.8.131.52 files in OneDrive the last time I updated the module.
Clean up OneDrive and Reinstall
To clean up the mess, I uninstalled the module and then deleted all the files from OneDrive. A retention label stopped OneDrive deleting the files, so it was a matter of removing the retention label and then deleting the files and folders.
I then reinstalled the module, making sure to select the correct version and to install the module for everyone who uses the PC.
Install-Module AzureADPreview -RequiredVersion "184.108.40.206" -Scope AllUsers
After the installation, the module files are in:
Get-Module -Name AzureADPreview | fl Name : AzureADPreview Path : C:\Program Files\WindowsPowerShell\Modules\AzureADPreview\220.127.116.11\ Microsoft.Open.AzureAD16.Graph.PowerShell.dll
The next time I started a PowerShell session and ran the Connect-AzureAD cmdlet, I got the right version.
All of which goes to prove that you should pay attention to how you install PowerShell modules, just in case the files end up in OneDrive. PowerShell works when modules are installed to OneDrive, but upgrades become a little more interesting.