Skip to content

'#Requires -Assembly' does not have any effect #11098

Closed
@Mettcon

Description

@Mettcon

Nothing get's loaded and it throws no error. No matter if it's valid input or not.
With Add-Type -Assembly 'Name.For.Assembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=123' could be loaded.
Requires for Administrator and Modules work like expected.

Steps to reproduce

@"
#Requires -RunAsAdministrator
#Requires -Assembly 'Name.For.Assembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=123'
Write-Host 'bla'
"@ > RequiresTest.ps1

Expected behavior

Expected it to work like Requires -Module ModuleName

Actual behavior

Like mentioned above, nothing happens.
The following showed no difference before and after execution

[System.AppDomain]::CurrentDomain.GetAssemblies() | select Fullname

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.0-preview.5
PSEdition                      Core
GitCommitId                    7.0.0-preview.5
OS                             Microsoft Windows 10.0.14393
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Name                           Value
----                           -----
PSVersion                      5.1.14393.206
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.206
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-DuplicateThe issue is a duplicate.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions