This script works great to accept some read-host prompts and create a website with an app pool tied to it. The password prompt works except our most common password is !$Pass!123!! and it will not allow me to receive it as input. How do you allow these characters to be used?
Import-Module WebAdministration
# Get Web Site Variables $WebSite = Read-Host -Prompt "DNS name for Web Site" $AppPoolName = Read-Host -Prompt "Application Pool Name" [string]$AppPoolUser = Read-Host -Prompt "Application Pool Username Domain not required ex. PXML.Proxy$" $Password = Read-Host -Prompt "Application Pool Account Password, try ` before $ in password" $HostHeader = Read-Host -Prompt "Host Header Name" # cmd /c C:\scripts\BaseIIS.cmd $WebServer $AppPool $AppPoolUser $Password $HostName New-Item -path d:\Websites -itemtype directory New-Item -path d:\Logs -itemtype directory New-Item -path d:\Logs\$WebSite -itemtype directory New-Item -path d:\websites\$WebSite -itemtype directory
The problem in the input isn’t the
dollar sign($)but the startingexclamation mark(!)You need to escape it with another one.
You password need to be inputed as: !!$Pass!123!!
Read here to know more about this
Why not using
get-credentialcmdlet:or you can use: