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 126.96.36.199 to 188.8.131.52.
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 184.108.40.206 was used.
Eventually I discovered that the 220.127.116.11 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\18.104.22.168\ Microsoft.Open.AzureAD16.Graph.PowerShell.dll
My speculation is that PowerShell installed the 22.214.171.124 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 "126.96.36.199" -Scope AllUsers
After the installation, the module files are in:
Get-Module -Name AzureADPreview | fl Name : AzureADPreview Path : C:\Program Files\WindowsPowerShell\Modules\AzureADPreview\188.8.131.52\ 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.