PSWebConfig is a PowerShell module that provides an easy way to automatically decrypt, inspect and test web.config or any .NET based application configuration files both locally or remotely.
PSWebConfig is available via PowerShell Gallery or PsGet, so you can simply install it with the following command:
Install-Module PSWebConfig
# Or alternatevely you can install it with PsGet from this repository
Install-Module -ModuleUrl https://github.com/murati-hu/PSWebConfig/archive/master.zip
Of course you can download and install the module manually too from Downloads
Import-Module PSWebConfig
Get-PSWebConfig
cmdlet automatically fetches and decrypts any web.config
file both locally and remotely without altering the actual config file on the
target computer:
# Pipe any site into Get-PSWebConfig to show the decrypted config
Get-Website | Get-PSWebConfig -AsText
# You can use -Path attribute to find web.config files
Get-PSWebConfig -Path C:\inetpub\wwwroot\
# If you wish to override the config with its decrypted version
Get-Website | Decrypt-PSWebConfig -Confirm $false
Test-PSWebConfig
function allows complete tests on all connectionStrings and
Service addresses from a configuration both on local or remote computers.
# Pipe a config into Test-PSWebConfig
Get-Website * | Test-PSWebConfig
# Or use -Session to test it via remote PSSession
$server1 = New-PSSession 'server1.local.domain'
Get-PSWebConfig -Path C:\inetpub\wwwroot\ -Session $server1 | Test-PSWebConfig
# Pipe Get-PSWebConfig into Get-PSConnectionString to get decrypted connectionstrings
Get-Website * | Get-PSWebConfig | Get-PSConnectionString
# You can also use -IncludeAppSettings to find connectionstrings from appSetting section
Get-PSWebConfig -Path C:\inetpub\wwwroot\ | Get-PSConnectionString -IncludeAppSettings
Test-PSConnectionString
cmdlet tries to initiate a SQL connection from a local or
remote computer to test if there are any issue connection to a database.
# Pipe Get-PSConnectionString to Test-PSConnectionString
Get-Website * | Get-PSWebConfig | Get-PSConnectionString -Inc | Test-PSConnectionString
# You can also transform the connectionString with regex -ReplaceRules hashtable
Test-PSConnectionString -Conn "Server=dbserver.local;Database=##TARGET_DB##" -ReplaceRules @{ '##TARGET_DB##'='myDb'}
# Pipe Get-PSWebConfig into Get-PSAppSetting to get decrypted appSettings
Get-Website * | Get-PSWebConfig | Get-PSAppSetting
# Pipe Get-PSWebConfig into Get-PSEndpoint to get decrypted webservice addresses
Get-Website * | Get-PSWebConfig | Get-PSEndpoint
# Or pipe Get-PSWebConfig into Get-PSUri to get URLs from appSettings too.
Get-Website * | Get-PSWebConfig | Get-PSUri
Call help
on any of the PSWebConfig cmdlets for more information and examples.
Cmdlets and functions for PSWebConfig have their own help PowerShell help, which
you can read with help <cmdlet-name>
.
PSWebConfig aims to adhere to Semantic Versioning 2.0.0.
In case of any issues, raise an issue ticket in this repository and/or feel free to contribute to this project if you have a possible fix for it.
- Source hosted at Github.com
- Report issues/questions/feature requests on Github Issues
Pull requests are very welcome! Make sure your patches are well tested. Ideally create a topic branch for every separate change you make. For example:
- Fork the repo
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Created and maintained by Akos Murati (akos@murati.hu).
Apache License, Version 2.0 (see LICENSE)