You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
PS C:\Users\Ace.Olszowka> c:\Users\Ace.Olszowka\Desktop\WebPortalRemovals\WhatIfRemotingBug.ps1
What if: Performing the operation "Copy File" on target "Item: C:\Users\Ace.Olszowka\AppData\Local\Temp\79\tmp_hi0s3iyz.hi4\remoteIpMoProxy_ActiveDirectory_1.0.0.0_localhost_99a12936-ef8b-469a-ba86-28da0c409df1.format.ps1xml Destination: C:\Users\Ace.Olszowka\AppData\Local\Temp\79\remoteIpMoProxy_ActiveDirectory_1.0.0.0_localhost_99a12936-ef8b-469a-ba86-28da0c409df1\remoteIpMoProxy_ActiveDirectory_1.0.0.0_localhost_99a12936-ef8b-469a-ba86-28da0c409df1.format.ps1xml".
What if: Performing the operation "Copy File" on target "Item: C:\Users\Ace.Olszowka\AppData\Local\Temp\79\tmp_hi0s3iyz.hi4\remoteIpMoProxy_ActiveDirectory_1.0.0.0_localhost_99a12936-ef8b-469a-ba86-28da0c409df1.psd1 Destination: C:\Users\Ace.Olszowka\AppData\Local\Temp\79\remoteIpMoProxy_ActiveDirectory_1.0.0.0_localhost_99a12936-ef8b-469a-ba86-28da0c409df1\remoteIpMoProxy_ActiveDirectory_1.0.0.0_localhost_99a12936-ef8b-469a-ba86-28da0c409df1.psd1".
What if: Performing the operation "Copy File" on target "Item: C:\Users\Ace.Olszowka\AppData\Local\Temp\79\tmp_hi0s3iyz.hi4\remoteIpMoProxy_ActiveDirectory_1.0.0.0_localhost_99a12936-ef8b-469a-ba86-28da0c409df1.psm1 Destination: C:\Users\Ace.Olszowka\AppData\Local\Temp\79\remoteIpMoProxy_ActiveDirectory_1.0.0.0_localhost_99a12936-ef8b-469a-ba86-28da0c409df1\remoteIpMoProxy_ActiveDirectory_1.0.0.0_localhost_99a12936-ef8b-469a-ba86-28da0c409df1.psm1".
What if: Performing the operation "Remove Directory" on target "C:\Users\Ace.Olszowka\AppData\Local\Temp\79\tmp_hi0s3iyz.hi4".
Get-ADUser: C:\Users\Ace.Olszowka\Desktop\WebPortalRemovals\WhatIfRemotingBug.ps1:8:9
Line |
8 | Get-ADUser -Filter "SamAccountName -eq 'Ace.Olszowka'"
| ~~~~~~~~~~
| The 'Get-ADUser' command was found in the module 'ActiveDirectory', but the module could not be loaded. For more information, run 'Import-Module ActiveDirectory'.
Any subsequent runs in this session with -WhatIf will fail.
However if you remove the -WhatIf and execute it, this runs without issue.
IN THAT SAME SESSION if you attempt to run the above again with -WhatIf it will succeed without issue.
Working Theory
Our guess is that there is some type of bug in this version of ActiveDirectory in combination with WindowsCompatibility that causes -WhatIf to be acted upon for the setup of the remoting call. This means that subsequent attempts to use the proxied module are futile. This would explain why running this same script in the same session at least once without a -WhatIf corrects the issue for subsequent -WhatIf calls.
Potential Workaround
Based on the above theory the following works around this issue in a clean session:
Issue
In PowerShell 7.1.3 when attempting to execute the following FROM A CLEAN SESSION we encounter an error.
Script:
Error:
Any subsequent runs in this session with
-WhatIf
will fail.However if you remove the
-WhatIf
and execute it, this runs without issue.IN THAT SAME SESSION if you attempt to run the above again with
-WhatIf
it will succeed without issue.Working Theory
Our guess is that there is some type of bug in this version of
ActiveDirectory
in combination withWindowsCompatibility
that causes-WhatIf
to be acted upon for the setup of the remoting call. This means that subsequent attempts to use the proxied module are futile. This would explain why running this same script in the same session at least once without a-WhatIf
corrects the issue for subsequent-WhatIf
calls.Potential Workaround
Based on the above theory the following works around this issue in a clean session:
We have proved that this works in our environment and have rolled this fix into production.
Environment
$PSVersionTable
:Get-Module -ListAvailable | Where-Object { $_.Name -eq 'ActiveDirectory' } | Select-Object *
:The text was updated successfully, but these errors were encountered: