Curah!
Microsoft developed Curah! as a way to help customers/developers discover great technical content. Curah! has a very specific purpose: to help people searching in Bing or Google find annotated collections of great content that specifically target common user questions.
Curah! is a simple and fun way to help others find great content on the internet. It is a curation service that enables you to share your expertise with others, collecting the sources that are truly helpful, accurate and trustworthy, and adding your own notes and guidance.
Tips and articles related to Software and Application Development. More articles will be shared on software technology and terminologies.
Nov 12, 2013
Reading application details using PowerShell
Windows PowerShell
Windows PowerShell is a task-based command-line shell and scripting language designed especially for system administration. In simple, it is task automation and configuartion management framework.
It helps IT professionals and power users control and automate the administration of the Windows operating system and applications like IIS etc that run on Windows with the help of Windows Management Instrumentation(WMI).
PowerShell can be downloaded from here.
PowerShell commands are called cmdlets. It lets you executes commands over command-prompt or Integrated Scripting Environment (ISE). Detailed list of cmdlets are available here.
Below example displays list of applications and directories under given Application Pool.
Import-Module WebAdministration
function Get-WebAppPoolApplications($webAppPoolName) {
$result = @()
$webAppPool = Get-Item ( Join-Path 'IIS:\AppPools' $webAppPoolName )
if ( $webAppPool -ne $null ) {
#For all web sites
#$webSites = Get-ChildItem 'IIS:\Sites'
#For only 'Default Web Site'
$webSites = Get-ChildItem 'IIS:\Sites' | where { $_.Name -eq 'Default Web Site' }
$webSites | % {
$webApplications = Get-ChildItem ( Join-Path 'IIS:\Sites' $_.Name ) |
where { $_.NodeType -eq 'application' }
$webFolders = Get-ChildItem ( Join-Path 'IIS:\Sites' $_.Name ) |
where { $_.NodeType -eq 'directory' }
$result += $webApplications |
where { $_.applicationPool -eq $webAppPoolName }
$result += $webFolders
}
}
#Export to CSV file
#$result | export-csv "list.csv"
$result
}
Get-WebAppPoolApplications('ASP.NET V2.0')
function Get-WebAppPoolApplications($webAppPoolName) {
$result = @()
$webAppPool = Get-Item ( Join-Path 'IIS:\AppPools' $webAppPoolName )
if ( $webAppPool -ne $null ) {
#For all web sites
#$webSites = Get-ChildItem 'IIS:\Sites'
#For only 'Default Web Site'
$webSites = Get-ChildItem 'IIS:\Sites' | where { $_.Name -eq 'Default Web Site' }
$webSites | % {
$webApplications = Get-ChildItem ( Join-Path 'IIS:\Sites' $_.Name ) |
where { $_.NodeType -eq 'application' }
$webFolders = Get-ChildItem ( Join-Path 'IIS:\Sites' $_.Name ) |
where { $_.NodeType -eq 'directory' }
$result += $webApplications |
where { $_.applicationPool -eq $webAppPoolName }
$result += $webFolders
}
}
#Export to CSV file
#$result | export-csv "list.csv"
$result
}
Get-WebAppPoolApplications('ASP.NET V2.0')
WebAdministration: Importing a web administration module. It lets you access IIS app pools and using few commands we will be able to get information about IIS. Above example works only with IIS 7.
Labels:
powershell
Subscribe to:
Posts (Atom)