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.
Locked
User avatar
bush3102
Posts: 8
Joined: Thu Apr 05, 2018 7:24 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
Joined: Thu Apr 05, 2018 7:24 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

}

Locked