-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-DuplicateThe issue is a duplicate.The issue is a duplicate.
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
I have a python script that runs a .ps1 file which includes commands from the Microsoft.PowerShell.Security module. Starting with 7.3.0, these commands fail to import during script execution. This can be reproduced from a PowerShell window:
python -c "import subprocess; subprocess.Popen('powershell -command Get-ExecutionPolicy')"
OR
python -c "import subprocess; subprocess.Popen('powershell -command Import-Module Microsoft.PowerShell.Security')"
Expected behavior
PS C:\> python -c "import subprocess; subprocess.Popen('powershell -command Get-ExecutionPolicy')"
PS C:\> Restricted
PS C:\> python -c "import subprocess; subprocess.Popen('powershell -command Import-Module Microsoft.PowerShell.Security')"
PS C:\>Actual behavior
PS C:\> python -c "import subprocess; subprocess.Popen('powershell -command Get-ExecutionPolicy')"
PS C:\> Get-ExecutionPolicy : The 'Get-ExecutionPolicy' command was found in the module 'Microsoft.PowerShell.Security', but the module could not be loaded. For more
information, run 'Import-Module Microsoft.PowerShell.Security'.
At line:1 char:1
+ Get-ExecutionPolicy
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-ExecutionPolicy:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
PS C:\> python -c "import subprocess; subprocess.Popen('powershell -command Import-Module Microsoft.PowerShell.Security')"
PS C:\> Import-Module : The following error occurred while loading the extended type data file: Error in TypeData "System.Security.AccessControl.ObjectSecurity": The
member AuditToString is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member AccessToString is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Sddl is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Access is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Group is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Owner is already present.
Error in TypeData "System.Security.AccessControl.ObjectSecurity": The member Path is already present.
At line:1 char:1
+ Import-Module Microsoft.PowerShell.Security
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Import-Module], RuntimeException
+ FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommandError details
No response
Environment data
PS> $PSVersionTable
Name Value
---- -----
PSVersion 7.3.0
PSEdition Core
GitCommitId 7.3.0
OS Microsoft Windows 10.0.22622
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
PS> python --version
Python 3.10.6Visuals
No response
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-DuplicateThe issue is a duplicate.The issue is a duplicate.