Created
March 22, 2024 15:24
-
-
Save mattman-ps/abe90162acbb6b36992cd4b5062c7e45 to your computer and use it in GitHub Desktop.
Create a Website object that protects the password string on Get-WebSite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I don't like passing a clear text password and it sounds like this will not be fixed anytime soon | |
# only an admin can run the WebAdministration module, but this could cause issues in some instances. | |
$IISSite = "mycoolsite" | |
Import-Module -Name WebAdministration | |
$SiteProperties = (Get-Website -Name $IISSite | Select-Object -Property *) | |
$SecurePassword = ConvertTo-SecureString -String $SiteProperties.password -AsPlainText -Force | |
$SiteProperties.password = $null | |
$SiteProperties | Add-Member -MemberType NoteProperty -Name "SecurePassword" -Value $SecurePassword | |
$SiteProperties | Format-List |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment