[System.Web.Security.Membership]::GeneratePassword() - Type Not found

Viewed 11745

Why do I get Type Not Found when trying to use this class/method in PowerShell?

 [System.Web.Security.Membership]::GeneratePassword()

Do I need to install a module or something to make use of it?

2 Answers

For those landing here who are using PowerShell Core, as per this link:

https://github.com/PowerShell/PowerShell/issues/5352

.NET Core does not support System.Web.dll

As such [System.Web.Security.Membership]::GeneratePassword() will result in the same Type Not Found error in PowerShell Core even with the add-type fix above.

You'll have to roll your own password generator.

Load the assembly first:

add-type -AssemblyName System.Web
[System.Web.Security.Membership]::GeneratePassword(10,0)
Related