Unable to find type [System Web Security Membership]

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 3 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
bush3102
Posts: 8
Last visit: Tue Feb 22, 2022 11:26 am

Unable to find type [System Web Security Membership]

Post by bush3102 »

Powershell Studio Version: 2020
Powershell version: 7 - 64 bit

I have a button that I want to generate a random password using the following code that will show the password in a textbox for the user to see. However, when I run the script I get the following error message: Unable to find type (periods should be between words) [System Web Security Membership]

But this script works fine, in regular Powershell ISE version 5.1.

Code: Select all

$buttonGeneratePassword_Click={
	#TODO: Place custom script here
	
	add-type -AssemblyName System.Web -PassThru
	
	$minLength = 15 ## characters
	$maxLength = 25 ## characters
	$length = Get-Random -Minimum $minLength -Maximum $maxLength
	$nonAlphaChars = 5
	$password = [System Web Security Membership]::GeneratePassword($length, $nonAlphaChars)
		
	$txtbxPassword.Text = $password
	
}
User avatar
bush3102
Posts: 8
Last visit: Tue Feb 22, 2022 11:26 am

Re: Unable to find type [System Web Security Membership]

Post by bush3102 »

System.Web.DLL is not part of .NetCore and will not work with Powershell 7. So I have to create my own password generator.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Unable to find type [System Web Security Membership]

Post by jvierra »

PowerShell 7 does not support subsystems that are Windows only and should not be used except when it is necessary to run code on non-windows systems. The module will never be available on non-windows systems due to architecture differences and products. Tis module is for IIS and SharePoint only.
User avatar
bush3102
Posts: 8
Last visit: Tue Feb 22, 2022 11:26 am

Re: Unable to find type [System Web Security Membership]

Post by bush3102 »

jvierra wrote: Mon Aug 10, 2020 5:58 pm PowerShell 7 does not support subsystems that are Windows only and should not be used except when it is necessary to run code on non-windows systems. The module will never be available on non-windows systems due to architecture differences and products. This module is for IIS and SharePoint only.
I was trying to use the Generate Password portion of System.Web. However, I went with the following password generator on GitHub.
This topic is 3 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked