Tag Archives: powershell

Generate IIS application with Powershell based on a list

powershellHere’s another simple code snippet to create an IIS application, set the name, physical path, protocol and set the version of the runtime for the AppPool. In that case we use a list of objects representing the applications we have to create.

# First load the mgmt module
import-module webadministration 
foreach($Application in $Applications)
{
	# Check if the app is not already existing. If yes, delete it.
	if(Test-Path 'iis:\Sites\Default Web Site\'$Application.Name)
	{
		# Delete the existing application
		Remove-Item 'iis:\Sites\Default Web Site\'$Application.Name
	}
	# Create the new one
	New-Item 'iis:\Sites\Default Web Site\'$Application.Name -physicalPath $Application.Path -type Application
	# Set the protocol
	Set-ItemProperty 'iis:\Sites\Default Web Site\'$Application.Name  -Name "enabledProtocols" -Value "http,net.tcp"
}
# Set the runtime version
Set-ItemProperty 'iis:\AppPools\DefaultAppPool' -name managedRuntimeVersion -Value 'v4.0'

Catch you next time and keep it bug free !

3 ways to list installed software with Powershell

powershell Here’s 3 little code snippet to get the software installed on the local machine using powershell. Usefull when scripting setups and deployment !

Slow but really complete.

Get-WmiObject -Class Win32_Product

Based on the software in Add/Remove Programs. Fast but may miss some software.

Get-WmiObject -Class Win32Reg_AddRemovePrograms

Based on the software registering in the registry for uninstall. Fast but may miss some software.

Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall |
% {Get-ItemProperty $_.PsPath} |
where {$_.Displayname -and ($_.Displayname -match ".*")} |
sort Displayname | select DisplayName, Publisher

Catch you next time and keep it bug free !