generating random password without special characters

Hi All
I am using below code to generate random password .

$pwd = [System.Web.Security.Membership]::GeneratePassword(15,2)
random password generated from above function is b}0-ad.GqCz:e>! how can i avoid generating special characters like "{" , "}" , please suggest.
i used below function and it worked thanks
Function New-SecurePassword {
    $Password = "!?@#$%^&*0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".tochararray()
    ($Password | Get-Random -Count 8) -Join ''

I think all you can do is delete or replace those characters after generating the password. The GeneratePassword method only accepts 2 arguments, length and number of non alpha numeric characters.

This link might help:


There are many homegrown password generators. You could take this fine example and just remove the characters/charactersets you don’t want.