Redirection of the \Documents\WindowsPowerShell folder to OneDrive cause issues with Az modules

%3CLINGO-SUB%20id%3D%22lingo-sub-2390961%22%20slang%3D%22en-US%22%3ERedirection%20of%20the%20%5CDocuments%5CWindowsPowerShell%20folder%20to%20OneDrive%20cause%20issues%20with%20Az%20modules%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2390961%22%20slang%3D%22en-US%22%3E%3CP%3EI%20would%20like%20to%20share%20my%20experience%20with%20redirected%20to%20OneDrive%20PowerShell%20folder.%3CBR%20%2F%3EOriginal%20path%20of%20the%20folder%3A%26nbsp%3B%3CBR%20%2F%3EC%3A%5CUsers%5C%3CUSERNAME%3E%5CDocuments%5CWindowsPowerShell%3CBR%20%2F%3ERedirected%20to%20OneDrive%20path%3A%3CBR%20%2F%3EC%3A%5CUsers%5C%3CUSERNAME%3E%5COneDrive%5CDocuments%5CWindowsPowerShell%3C%2FUSERNAME%3E%3C%2FUSERNAME%3E%3C%2FP%3E%3CP%3ESince%20folder%20was%20redirected%2C%20I%20get%20issues%20with%20uninstall%20of%20previous%20versions%20of%20the%3CBR%20%2F%3EAz%20PowerShell%20modules.%3C%2FP%3E%3CP%3ECmdlet%20Uninstall-Module%20with%20option%20-Force%20return%20successful%20result%20of%20the%20module%3CBR%20%2F%3Edelete%20operation%2C%20while%20modules%20folders%20remains%20in%3CBR%20%2F%3EC%3A%5CUsers%5C%3CUSERNAME%3E%5COneDrive%5CDocuments%5CWindowsPowerShell%5CModules%20folder.%3C%2FUSERNAME%3E%3C%2FP%3E%3CP%3EI%20set%20option%20%22Always%20keep%20on%20device%22%20for%20WindowsPowerShell%20folder%2C%20retry%20delete%3CBR%20%2F%3Eoperation%2C%20same%20result.%3C%2FP%3E%3CP%3EAs%20workaround%20I%20use%20following%20solution%20-%20delete%20all%20Az%20modules%20folders%20from%3CBR%20%2F%3EModules%20folder.%3CBR%20%2F%3ESince%20then%20I%20was%20able%20to%20uninstall%20old%20versions%20of%20the%20Az%20PowerShell%20modules%20in%3CBR%20%2F%3EC%3A%5CProgram%20Files%5CWindowsPowerShell%5CModules%20folder.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPowerShell%20work%20paths%20remains%20without%20changes.%20Would%20be%20great%20to%20have%20option%20in%3CBR%20%2F%3EOneDrive%20sync%26nbsp%3Bsettings%20to%20exclude%26nbsp%3BDocuments%5CWindowsPowerShell%5C%20folder%20from%3CBR%20%2F%3Eredirection%20to%20OneDrive.%3CBR%20%2F%3E%3CBR%20%2F%3EUseful%20information%20about%20uninstall%20procedure%20of%20Az%20modules%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fazure%2Funinstall-az-ps%3Fview%3Dazps-6.0.0%22%20rel%3D%22noopener%20noreferrer%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fazure%2Funinstall-az-ps%3Fview%3Dazps-6.0.0%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I would like to share my experience with redirected to OneDrive PowerShell folder.
Original path of the folder: 
C:\Users\<username>\Documents\WindowsPowerShell
Redirected to OneDrive path:
C:\Users\<username>\OneDrive\Documents\WindowsPowerShell

Since folder was redirected, I get issues with uninstall of previous versions of the
Az PowerShell modules.

Cmdlet Uninstall-Module with option -Force return successful result of the module
delete operation, while modules folders remains in
C:\Users\<username>\OneDrive\Documents\WindowsPowerShell\Modules folder.

I set option "Always keep on device" for WindowsPowerShell folder, retry delete
operation, same result.

As workaround I use following solution - delete all Az modules folders from
Modules folder.
Since then I was able to uninstall old versions of the Az PowerShell modules in
C:\Program Files\WindowsPowerShell\Modules folder.

 

PowerShell work paths remains without changes. Would be great to have option in
OneDrive sync settings to exclude Documents\WindowsPowerShell\ folder from
redirection to OneDrive.

Useful information about uninstall procedure of Az modules:
https://docs.microsoft.com/en-us/powershell/azure/uninstall-az-ps?view=azps-6.0.0

 

0 Replies