Problem posting a problem

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 7 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

Problem posting a problem

Post by bush3102 »

I am trying to post a new topic with some Powershell code in it, but I get the following message when trying to preview my message. I don't have any external links in my question, just the script I have a question about.

Sorry. You need to have made a minimum of 5 posts before you can include external links in your posts.

Any suggestions?
User avatar
bush3102
Posts: 8
Last visit: Tue Feb 22, 2022 11:26 am

Re: Problem posting a problem

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 would appear between each word) [System Web Security Membership]

$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

}
This topic is 3 years and 7 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