Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find type [Privileges] #13

Open
jmbreuer opened this issue Sep 13, 2023 · 1 comment
Open

Unable to find type [Privileges] #13

jmbreuer opened this issue Sep 13, 2023 · 1 comment

Comments

@jmbreuer
Copy link

I'm trying to use PoshPrivilege on Windows 10 (22H2, 10.0.19045), PowerShell 7.6.3 (since I need a working Set-Acl -LiteralPath in conjunction with this, the shipped PS 5.1 is not an option).

After installing via Install-Module -Name PoshPrivilege, when trying to run any of the provided commands, I get (for example):

PS> Get-Privilege
InvalidOperation: \\local.domain\DFS\User$\Home\...\PowerShell\Modules\PoshPrivilege\0.3.0.0\Scripts\Get-Privilege.ps1:101
Line |
 101 |          [Privileges[]]$Privilege,
     |          ~~~~~~~~~~~~~~
     | Unable to find type [Privileges].

What am I missing to make this work?

@jmbreuer
Copy link
Author

OK, it is a PowerShell 7 thing - in PowerShell 5.1 on the same machine PoshPrivilege works.

Through some digging (running Import-Module PoshPrivilege -Force -Verbose gave a ton of error messages pointing me in the direction of DefineDynamicAssembly), I found this.

Equipped with that knowledge, Import-Module PoshPrivilege -UseWindowsPowerShell -Force -Verbose allows PoshPrivelege to work within PowerShell 7, no errors on loading or so far for me.

On the page mentioned above I see that there's also a method to get this done implicitly, but I haven't dug further for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant