Categories
Sponsors
Archive
Blogroll
Badges
Community
|
Posted in Windows Server | No Comment | 2,202 views | 10/11/2015 15:10
You can get Database Index Fragmentation Reports with following query:
SELECT object_name(ps.object_id) AS [name],
ps.index_id,
i.name AS IndexName,
ps.avg_fragmentation_in_percent,
ps.fragment_count,
ps.avg_fragment_size_in_pages,
ps.page_count
FROM sys.dm_db_index_physical_stats(DB_ID(),NULL,NULL,NULL,NULL) ps
LEFT JOIN sys.indexes i ON i.object_id=ps.object_id AND i.index_id=ps.index_id
WHERE ps.avg_fragmentation_in_percent > 10
AND ps.page_count > 100
ORDER BY ps.avg_fragmentation_in_percent DESC |
select object_name(ps.object_id) as [name],
ps.index_id,
i.name as IndexName,
ps.avg_fragmentation_in_percent,
ps.fragment_count,
ps.avg_fragment_size_in_pages,
ps.page_count
from sys.dm_db_index_physical_stats(DB_ID(),null,null,null,null) ps
left join sys.indexes i on i.object_id=ps.object_id and i.index_id=ps.index_id
where ps.avg_fragmentation_in_percent > 10
and ps.page_count > 100
order by ps.avg_fragmentation_in_percent desc
You can check MSDN for more information about sys.dm_db_index_physical_stats.
Posted in Windows Server | No Comment | 1,926 views | 10/11/2015 15:07
Following query will give you details about SP usage:
SELECT DB_NAME(database_id) DBName,
OBJECT_NAME(object_id) SPName,
last_execution_time LastExec,
last_elapsed_time/1000 LastTimeMS,
last_worker_time/1000 LastWorkerCPU,
last_physical_reads LastPReads,
last_logical_writes LastLWrites,
last_logical_reads LastLReads
FROM sys.dm_exec_procedure_stats
WHERE database_id = DB_ID() |
SELECT DB_NAME(database_id) DBName,
OBJECT_NAME(object_id) SPName,
last_execution_time LastExec,
last_elapsed_time/1000 LastTimeMS,
last_worker_time/1000 LastWorkerCPU,
last_physical_reads LastPReads,
last_logical_writes LastLWrites,
last_logical_reads LastLReads
FROM sys.dm_exec_procedure_stats
WHERE database_id = DB_ID()
If you need to get all custom SPs in one query:
SELECT DB_NAME(database_id) DBName,
OBJECT_NAME(object_id) SPName,
last_execution_time LastExec,
last_elapsed_time/1000 LastTimeMS,
last_worker_time/1000 LastWorkerCPU,
last_physical_reads LastPReads,
last_logical_writes LastLWrites,
last_logical_reads LastLReads
FROM sys.dm_exec_procedure_stats
WHERE database_id > 4 AND database_id < 32767 |
SELECT DB_NAME(database_id) DBName,
OBJECT_NAME(object_id) SPName,
last_execution_time LastExec,
last_elapsed_time/1000 LastTimeMS,
last_worker_time/1000 LastWorkerCPU,
last_physical_reads LastPReads,
last_logical_writes LastLWrites,
last_logical_reads LastLReads
FROM sys.dm_exec_procedure_stats
WHERE database_id > 4 and database_id < 32767
Just filtered last stats, but you can use SELECT * to get all stats.
Posted in Windows Server | No Comment | 1,843 views | 10/11/2015 15:01
If you need to get all table column names from MSSQL database, you can use following query:
SELECT
o.name, c.name
FROM sys.columns c
INNER JOIN sys.objects o ON c.object_id=o.object_id
ORDER BY o.name, c.column_id |
select
o.name, c.name
from sys.columns c
inner join sys.objects o on c.object_id=o.object_id
order by o.name, c.column_id
That will output all column names.
Posted in Windows Powershell, Windows Server | No Comment | 1,912 views | 04/10/2015 20:22
Windows Containers are finally here! Lets start our new series :)
Container management is very similar to Hyper-V management. For example:
Lets check our commands:
PS C:\Users\Administrator> get-command *container*
CommandType Name Version Source
----------- ---- ------- ------
Function Install-ContainerOSImage 1.0.0.0 Containers
Function Uninstall-ContainerOSImage 1.0.0.0 Containers
Cmdlet Add-ContainerNetworkAdapter 1.0.0.0 Containers
Cmdlet Connect-ContainerNetworkAdapter 1.0.0.0 Containers
Cmdlet Disconnect-ContainerNetworkAdapter 1.0.0.0 Containers
Cmdlet Export-ContainerImage 1.0.0.0 Containers
Cmdlet Get-Container 1.0.0.0 Containers
Cmdlet Get-ContainerHost 1.0.0.0 Containers
Cmdlet Get-ContainerImage 1.0.0.0 Containers
Cmdlet Get-ContainerNetworkAdapter 1.0.0.0 Containers
Cmdlet Import-ContainerImage 1.0.0.0 Containers
Cmdlet Move-ContainerImageRepository 1.0.0.0 Containers
Cmdlet New-Container 1.0.0.0 Containers
Cmdlet New-ContainerImage 1.0.0.0 Containers
Cmdlet Remove-Container 1.0.0.0 Containers
Cmdlet Remove-ContainerImage 1.0.0.0 Containers
Cmdlet Remove-ContainerNetworkAdapter 1.0.0.0 Containers
Cmdlet Set-ContainerNetworkAdapter 1.0.0.0 Containers
Cmdlet Start-Container 1.0.0.0 Containers
Cmdlet Stop-Container 1.0.0.0 Containers
Cmdlet Test-ContainerImage 1.0.0.0 Containers |
PS C:\Users\Administrator> get-command *container*
CommandType Name Version Source
----------- ---- ------- ------
Function Install-ContainerOSImage 1.0.0.0 Containers
Function Uninstall-ContainerOSImage 1.0.0.0 Containers
Cmdlet Add-ContainerNetworkAdapter 1.0.0.0 Containers
Cmdlet Connect-ContainerNetworkAdapter 1.0.0.0 Containers
Cmdlet Disconnect-ContainerNetworkAdapter 1.0.0.0 Containers
Cmdlet Export-ContainerImage 1.0.0.0 Containers
Cmdlet Get-Container 1.0.0.0 Containers
Cmdlet Get-ContainerHost 1.0.0.0 Containers
Cmdlet Get-ContainerImage 1.0.0.0 Containers
Cmdlet Get-ContainerNetworkAdapter 1.0.0.0 Containers
Cmdlet Import-ContainerImage 1.0.0.0 Containers
Cmdlet Move-ContainerImageRepository 1.0.0.0 Containers
Cmdlet New-Container 1.0.0.0 Containers
Cmdlet New-ContainerImage 1.0.0.0 Containers
Cmdlet Remove-Container 1.0.0.0 Containers
Cmdlet Remove-ContainerImage 1.0.0.0 Containers
Cmdlet Remove-ContainerNetworkAdapter 1.0.0.0 Containers
Cmdlet Set-ContainerNetworkAdapter 1.0.0.0 Containers
Cmdlet Start-Container 1.0.0.0 Containers
Cmdlet Stop-Container 1.0.0.0 Containers
Cmdlet Test-ContainerImage 1.0.0.0 Containers
I can create a new container with following command:
New-Container -Name "MyContainer" -ContainerImageName WindowsServerCore -SwitchName "Virtual Switch" |
New-Container -Name "MyContainer" -ContainerImageName WindowsServerCore -SwitchName "Virtual Switch"
If you install Windows Containers with Microsoft Documentation, then you should have a virtual switch called “Virtual Switch” in your environment.
New-Container accepts many parameters:
NAME
New-Container
SYNTAX
New-Container [[-Name] <string>] -ContainerImageName <string> [-ContainerImagePublisher <string>]
[-ContainerImageVersion <version>] [-CimSession <CimSession[]>] [-ComputerName <string[]>] [-Credential
<pscredential[]>] [-MemoryStartupBytes <long>] [-SwitchName <string>] [-Path <string>] [-AsJob] [-WhatIf]
[-Confirm] [<CommonParameters>]
New-Container [[-Name] <string>] -ContainerImage <ContainerImage> [-MemoryStartupBytes <long>] [-SwitchName
<string>] [-Path <string>] [-AsJob] [-WhatIf] [-Confirm] [<CommonParameters>] |
NAME
New-Container
SYNTAX
New-Container [[-Name] <string>] -ContainerImageName <string> [-ContainerImagePublisher <string>]
[-ContainerImageVersion <version>] [-CimSession <CimSession[]>] [-ComputerName <string[]>] [-Credential
<pscredential[]>] [-MemoryStartupBytes <long>] [-SwitchName <string>] [-Path <string>] [-AsJob] [-WhatIf]
[-Confirm] [<CommonParameters>]
New-Container [[-Name] <string>] -ContainerImage <ContainerImage> [-MemoryStartupBytes <long>] [-SwitchName
<string>] [-Path <string>] [-AsJob] [-WhatIf] [-Confirm] [<CommonParameters>]
There is a parameter called “MemoryStartupBytes” but it seems it just changes startup memory. It seems there is no memory or processor limit yet.
Starting Container is similar like Hyper-V VMs:
Start-Container -Name "MyContainer" |
Start-Container -Name "MyContainer"
After start your container, you should configure your Host’s Firewall because Container uses Host Firewall. If you try to configure firewall inside Container, you will get warning.
You can use Enter-PSSession like in Hyper-V VMs to connect Container:
Enter-PSSession -ContainerId (Get-Container MyContainer).ContainerId -RunAsAdministrator |
Enter-PSSession -ContainerId (Get-Container MyContainer).ContainerId -RunAsAdministrator
You can disable firewall with following command to test RDP connection:
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False |
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
After that, you may have to enable Administrator account in Container with:
net use administrator /active:yes
net use administrator Password1! |
net use administrator /active:yes
net use administrator Password1!
See you in next part!
Posted in Windows Powershell | No Comment | 1,272 views | 21/09/2015 17:39
These are IIS Website properties that you can get using CIM via PowerShell.
1
2
3
4
5
6
7
8
9
10
| # Get WebSites
$WebSites = Get-CimInstance -Namespace "root\MicrosoftIISv2" -ClassName "IIsWebServerSetting" -OperationTimeoutSec 15 -EA Stop
$WebSite = $WebSites[0];
# WebSite Cache Information
[string]$WebSiteCacheControlCustom = $WebSite.CacheControlCustom
[string]$WebSiteCacheControlMaxAge = $WebSite.CacheControlMaxAge
[string]$WebSiteCacheControlNoCache = $WebSite.CacheControlNoCache
[string]$WebSiteCacheISAPI = $WebSite.CacheISAPI |
# Get WebSites
$WebSites = Get-CimInstance -Namespace "root\MicrosoftIISv2" -ClassName "IIsWebServerSetting" -OperationTimeoutSec 15 -EA Stop
$WebSite = $WebSites[0];
# WebSite Cache Information
[string]$WebSiteCacheControlCustom = $WebSite.CacheControlCustom
[string]$WebSiteCacheControlMaxAge = $WebSite.CacheControlMaxAge
[string]$WebSiteCacheControlNoCache = $WebSite.CacheControlNoCache
[string]$WebSiteCacheISAPI = $WebSite.CacheISAPI
You can find more properties in my blog.
Posted in Windows Server | No Comment | 2,001 views | 12/09/2015 17:19
You can send extra parameters to HTML.Partial with following example:
@{Html.RenderPartial("~/Views/Shared/GlobalScripts.cshtml", new ViewDataDictionary { { "timeRangeSessionValue", timeRangeSessionValue }, { "apiUrl", apiUrl } });} |
@{Html.RenderPartial("~/Views/Shared/GlobalScripts.cshtml", new ViewDataDictionary { { "timeRangeSessionValue", timeRangeSessionValue }, { "apiUrl", apiUrl } });}
You can get parameters with following:
You can populate parameters.
Posted in Windows Powershell | No Comment | 2,101 views | 04/09/2015 17:15
This is an example for StringBuilder in PowerShell. This is fast :)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
| # IIS: Application Pools
# PowerShell String Builder
$HostIISAppPoolsStringBuilder = New-Object System.Text.StringBuilder
# Append to String Builder
$Null = $HostIISAppPoolsStringBuilder.Append("[")
# Get IIS Application Pools
$IISServerManager.ApplicationPools | % {
# Clear Variables
$HostIISAppPoolName = $Null;
$HostIISAppPoolStartMode = $Null;
$HostIISAppPoolEnable32BitAppOnWin64 = $Null;
$HostIISAppPoolManagedPipelineMode = $Null;
$HostIISAppPoolManagedRuntimeVersion = $Null;
$HostIISAppPoolQueueLength = $Null;
$HostIISAppPoolAutoStart = $Null;
$HostIISAppPoolState = $Null;
$HostIISAppPoolCpuAction = $Null;
$HostIISAppPoolCpuLimit = $Null;
$HostIISAppPoolCpuResetInterval = $Null;
$HostIISAppPoolRapidFailProtection = $Null;
$HostIISAppPoolRapidFailProtectionInterval = $Null;
$HostIISAppPoolRapidFailProtectionMaxCrashes = $Null;
$HostIISAppPoolIdentityType = $Null;
$HostIISAppPoolIdleTimeout = $Null;
$HostIISAppPoolIdleTimeoutAction = $Null;
$HostIISAppPoolShutdownTimeLimit = $Null;
$HostIISAppPoolStartupTimeLimit = $Null;
$HostIISAppPoolMaxProcesses = $Null;
$HostIISAppPoolPingingEnabled = $Null;
$HostIISAppPoolPingInterval = $Null;
$HostIISAppPoolPingResponseTime = $Null;
$HostIISAppPoolLogEventOnProcessModel = $Null;
$HostIISAppPoolLogEventOnRecycle = $Null;
$HostIISAppPoolRecycleMemory = $Null;
$HostIISAppPoolRecyclePrivateMemory = $Null;
$HostIISAppPoolRecycleRequests = $Null;
$HostIISAppPoolRecycleTime = $Null;
# Get IIS AppPool Properties
$HostIISAppPoolName = $_.Name;
$HostIISAppPoolStartMode = $_.StartMode;
$HostIISAppPoolEnable32BitAppOnWin64 = $_.Enable32BitAppOnWin64;
$HostIISAppPoolManagedPipelineMode = $_.ManagedPipelineMode;
$HostIISAppPoolManagedRuntimeVersion = $_.ManagedRuntimeVersion;
$HostIISAppPoolQueueLength = $_.QueueLength;
$HostIISAppPoolAutoStart = $_.AutoStart;
$HostIISAppPoolState = $_.State;
$HostIISAppPoolCpuAction = $_.Cpu.Action;
$HostIISAppPoolCpuLimit = $_.Cpu.Limit;
$HostIISAppPoolCpuResetInterval = $_.Cpu.ResetInterval.ToString();
$HostIISAppPoolRapidFailProtection = $_.Failure.RapidFailProtection;
$HostIISAppPoolRapidFailProtectionInterval = $_.Failure.RapidFailProtectionInterval.ToString();
$HostIISAppPoolRapidFailProtectionMaxCrashes = $_.Failure.RapidFailProtectionMaxCrashes;
$HostIISAppPoolIdentityType = $_.ProcessModel.IdentityType;
$HostIISAppPoolIdleTimeout = $_.ProcessModel.IdleTimeout.ToString();
$HostIISAppPoolIdleTimeoutAction = $_.ProcessModel.IdleTimeoutAction;
$HostIISAppPoolShutdownTimeLimit = $_.ProcessModel.ShutdownTimeLimit.ToString();
$HostIISAppPoolStartupTimeLimit = $_.ProcessModel.StartupTimeLimit.ToString();
$HostIISAppPoolMaxProcesses = $_.ProcessModel.MaxProcesses;
$HostIISAppPoolPingingEnabled = $_.ProcessModel.PingingEnabled;
$HostIISAppPoolPingInterval = $_.ProcessModel.PingInterval.ToString();
$HostIISAppPoolPingResponseTime = $_.ProcessModel.PingResponseTime.ToString();
$HostIISAppPoolLogEventOnProcessModel = $_.ProcessModel.LogEventOnProcessModel;
$HostIISAppPoolLogEventOnRecycle = $_.Recycling.LogEventOnRecycle;
$HostIISAppPoolRecycleMemory = $_.Recycling.PeriodicRestart.Memory;
$HostIISAppPoolRecyclePrivateMemory = $_.Recycling.PeriodicRestart.PrivateMemory;
$HostIISAppPoolRecycleRequests = $_.Recycling.PeriodicRestart.Requests;
$HostIISAppPoolRecycleTime = $_.Recycling.PeriodicRestart.Time.ToString();
# Parameter Validation
if($HostIISAppPoolName -eq $Null) { $HostIISAppPoolName = "Unknown"; }
if($HostIISAppPoolStartMode -eq $Null) { $HostIISAppPoolStartMode = "Unknown"; }
if($HostIISAppPoolEnable32BitAppOnWin64 -eq $Null) { $HostIISAppPoolEnable32BitAppOnWin64 = "Unknown"; }
if($HostIISAppPoolManagedPipelineMode -eq $Null) { $HostIISAppPoolManagedPipelineMode = "Unknown"; }
if($HostIISAppPoolManagedRuntimeVersion -eq $Null) { $HostIISAppPoolManagedRuntimeVersion = "Unknown"; }
if($HostIISAppPoolQueueLength -eq $Null) { $HostIISAppPoolQueueLength = "-1"; }
if($HostIISAppPoolAutoStart -eq $Null) { $HostIISAppPoolAutoStart = "Unknown"; }
if($HostIISAppPoolState -eq $Null) { $HostIISAppPoolState = "Unknown"; }
if($HostIISAppPoolCpuAction -eq $Null) { $HostIISAppPoolCpuAction = "Unknown"; }
if($HostIISAppPoolCpuLimit -eq $Null) { $HostIISAppPoolCpuLimit = "Unknown"; }
if($HostIISAppPoolCpuResetInterval -eq $Null) { $HostIISAppPoolCpuResetInterval = "Unknown"; }
if($HostIISAppPoolRapidFailProtection -eq $Null) { $HostIISAppPoolRapidFailProtection = "Unknown"; }
if($HostIISAppPoolRapidFailProtectionInterval -eq $Null) { $HostIISAppPoolRapidFailProtectionInterval = "Unknown"; }
if($HostIISAppPoolRapidFailProtectionMaxCrashes -eq $Null) { $HostIISAppPoolRapidFailProtectionMaxCrashes = "-1"; }
if($HostIISAppPoolIdentityType -eq $Null) { $HostIISAppPoolIdentityType = "Unknown"; }
if($HostIISAppPoolIdleTimeout -eq $Null) { $HostIISAppPoolIdleTimeout = "Unknown"; }
if($HostIISAppPoolIdleTimeoutAction -eq $Null) { $HostIISAppPoolIdleTimeoutAction = "Unknown"; }
if($HostIISAppPoolShutdownTimeLimit -eq $Null) { $HostIISAppPoolShutdownTimeLimit = "Unknown"; }
if($HostIISAppPoolStartupTimeLimit -eq $Null) { $HostIISAppPoolStartupTimeLimit = "Unknown"; }
if($HostIISAppPoolMaxProcesses -eq $Null) { $HostIISAppPoolMaxProcesses = "-1"; }
if($HostIISAppPoolPingingEnabled -eq $Null) { $HostIISAppPoolPingingEnabled = "Unknown"; }
if($HostIISAppPoolPingInterval -eq $Null) { $HostIISAppPoolPingInterval = "Unknown"; }
if($HostIISAppPoolPingResponseTime -eq $Null) { $HostIISAppPoolPingResponseTime = "Unknown"; }
if($HostIISAppPoolLogEventOnProcessModel -eq $Null) { $HostIISAppPoolLogEventOnProcessModel = "Unknown"; }
if($HostIISAppPoolLogEventOnRecycle -eq $Null) { $HostIISAppPoolLogEventOnRecycle = "Unknown"; }
if($HostIISAppPoolRecycleMemory -eq $Null) { $HostIISAppPoolRecycleMemory = "-1"; }
if($HostIISAppPoolRecyclePrivateMemory -eq $Null) { $HostIISAppPoolRecyclePrivateMemory = "-1"; }
if($HostIISAppPoolRecycleRequests -eq $Null) { $HostIISAppPoolRecycleRequests = "-1"; }
if($HostIISAppPoolRecycleTime -eq $Null) { $HostIISAppPoolRecycleTime = "Unknown"; }
# Create Host IIS App Pool Json Data
$HostIISAppPoolJson = @{
ReportDate = "$VMReportDate"
HostID = "$VirtualMetricHostID"
HostName = "$VirtualMetricHostName"
FQDN = "$VirtualMetricHostFQDN"
Name = "$HostIISAppPoolName"
StartMode = "$HostIISAppPoolStartMode"
Enable32BitAppOnWin64 = "$HostIISAppPoolEnable32BitAppOnWin64"
ManagedPipelineMode = "$HostIISAppPoolManagedPipelineMode"
ManagedRuntimeVersion = "$HostIISAppPoolManagedRuntimeVersion"
QueueLength = "$HostIISAppPoolQueueLength"
AutoStart = "$HostIISAppPoolAutoStart"
State = "$HostIISAppPoolState"
CpuAction = "$HostIISAppPoolCpuAction"
CpuLimit = "$HostIISAppPoolCpuLimit"
CpuResetInterval = "$HostIISAppPoolCpuResetInterval"
RapidFailProtection = "$HostIISAppPoolRapidFailProtection"
RapidFailProtectionInterval = "$HostIISAppPoolRapidFailProtectionInterval"
RapidFailProtectionMaxCrashes = "$HostIISAppPoolRapidFailProtectionMaxCrashes"
IdentityType = "$HostIISAppPoolIdentityType"
IdleTimeout = "$HostIISAppPoolIdleTimeout"
IdleTimeoutAction = "$HostIISAppPoolIdleTimeoutAction"
ShutdownTimeLimit = "$HostIISAppPoolShutdownTimeLimit"
StartupTimeLimit = "$HostIISAppPoolStartupTimeLimit"
MaxProcesses = "$HostIISAppPoolMaxProcesses"
PingingEnabled = "$HostIISAppPoolPingingEnabled"
PingInterval = "$HostIISAppPoolPingInterval"
PingResponseTime = "$HostIISAppPoolPingResponseTime"
LogEventOnProcessModel = "$HostIISAppPoolLogEventOnProcessModel"
LogEventOnRecycle = "$HostIISAppPoolLogEventOnRecycle"
RecycleMemory = "$HostIISAppPoolRecycleMemory"
RecyclePrivateMemory = "$HostIISAppPoolRecyclePrivateMemory"
RecycleRequests = "$HostIISAppPoolRecycleRequests"
RecycleTime = "$HostIISAppPoolRecycleTime"
}| ConvertTo-Json -Compress
# Append to String Builder
$Null = $HostIISAppPoolsStringBuilder.Append("$HostIISAppPoolJson`r`n")
# Append to String Builder
$Null = $HostIISAppPoolsStringBuilder.Append(",")
}
# Append to String Builder
$Null = $HostIISAppPoolsStringBuilder.Append("{}]")
# Get Output String
$HostIISAppPoolsOutputString = $HostIISAppPoolsStringBuilder.ToString() |
# IIS: Application Pools
# PowerShell String Builder
$HostIISAppPoolsStringBuilder = New-Object System.Text.StringBuilder
# Append to String Builder
$Null = $HostIISAppPoolsStringBuilder.Append("[")
# Get IIS Application Pools
$IISServerManager.ApplicationPools | % {
# Clear Variables
$HostIISAppPoolName = $Null;
$HostIISAppPoolStartMode = $Null;
$HostIISAppPoolEnable32BitAppOnWin64 = $Null;
$HostIISAppPoolManagedPipelineMode = $Null;
$HostIISAppPoolManagedRuntimeVersion = $Null;
$HostIISAppPoolQueueLength = $Null;
$HostIISAppPoolAutoStart = $Null;
$HostIISAppPoolState = $Null;
$HostIISAppPoolCpuAction = $Null;
$HostIISAppPoolCpuLimit = $Null;
$HostIISAppPoolCpuResetInterval = $Null;
$HostIISAppPoolRapidFailProtection = $Null;
$HostIISAppPoolRapidFailProtectionInterval = $Null;
$HostIISAppPoolRapidFailProtectionMaxCrashes = $Null;
$HostIISAppPoolIdentityType = $Null;
$HostIISAppPoolIdleTimeout = $Null;
$HostIISAppPoolIdleTimeoutAction = $Null;
$HostIISAppPoolShutdownTimeLimit = $Null;
$HostIISAppPoolStartupTimeLimit = $Null;
$HostIISAppPoolMaxProcesses = $Null;
$HostIISAppPoolPingingEnabled = $Null;
$HostIISAppPoolPingInterval = $Null;
$HostIISAppPoolPingResponseTime = $Null;
$HostIISAppPoolLogEventOnProcessModel = $Null;
$HostIISAppPoolLogEventOnRecycle = $Null;
$HostIISAppPoolRecycleMemory = $Null;
$HostIISAppPoolRecyclePrivateMemory = $Null;
$HostIISAppPoolRecycleRequests = $Null;
$HostIISAppPoolRecycleTime = $Null;
# Get IIS AppPool Properties
$HostIISAppPoolName = $_.Name;
$HostIISAppPoolStartMode = $_.StartMode;
$HostIISAppPoolEnable32BitAppOnWin64 = $_.Enable32BitAppOnWin64;
$HostIISAppPoolManagedPipelineMode = $_.ManagedPipelineMode;
$HostIISAppPoolManagedRuntimeVersion = $_.ManagedRuntimeVersion;
$HostIISAppPoolQueueLength = $_.QueueLength;
$HostIISAppPoolAutoStart = $_.AutoStart;
$HostIISAppPoolState = $_.State;
$HostIISAppPoolCpuAction = $_.Cpu.Action;
$HostIISAppPoolCpuLimit = $_.Cpu.Limit;
$HostIISAppPoolCpuResetInterval = $_.Cpu.ResetInterval.ToString();
$HostIISAppPoolRapidFailProtection = $_.Failure.RapidFailProtection;
$HostIISAppPoolRapidFailProtectionInterval = $_.Failure.RapidFailProtectionInterval.ToString();
$HostIISAppPoolRapidFailProtectionMaxCrashes = $_.Failure.RapidFailProtectionMaxCrashes;
$HostIISAppPoolIdentityType = $_.ProcessModel.IdentityType;
$HostIISAppPoolIdleTimeout = $_.ProcessModel.IdleTimeout.ToString();
$HostIISAppPoolIdleTimeoutAction = $_.ProcessModel.IdleTimeoutAction;
$HostIISAppPoolShutdownTimeLimit = $_.ProcessModel.ShutdownTimeLimit.ToString();
$HostIISAppPoolStartupTimeLimit = $_.ProcessModel.StartupTimeLimit.ToString();
$HostIISAppPoolMaxProcesses = $_.ProcessModel.MaxProcesses;
$HostIISAppPoolPingingEnabled = $_.ProcessModel.PingingEnabled;
$HostIISAppPoolPingInterval = $_.ProcessModel.PingInterval.ToString();
$HostIISAppPoolPingResponseTime = $_.ProcessModel.PingResponseTime.ToString();
$HostIISAppPoolLogEventOnProcessModel = $_.ProcessModel.LogEventOnProcessModel;
$HostIISAppPoolLogEventOnRecycle = $_.Recycling.LogEventOnRecycle;
$HostIISAppPoolRecycleMemory = $_.Recycling.PeriodicRestart.Memory;
$HostIISAppPoolRecyclePrivateMemory = $_.Recycling.PeriodicRestart.PrivateMemory;
$HostIISAppPoolRecycleRequests = $_.Recycling.PeriodicRestart.Requests;
$HostIISAppPoolRecycleTime = $_.Recycling.PeriodicRestart.Time.ToString();
# Parameter Validation
if($HostIISAppPoolName -eq $Null) { $HostIISAppPoolName = "Unknown"; }
if($HostIISAppPoolStartMode -eq $Null) { $HostIISAppPoolStartMode = "Unknown"; }
if($HostIISAppPoolEnable32BitAppOnWin64 -eq $Null) { $HostIISAppPoolEnable32BitAppOnWin64 = "Unknown"; }
if($HostIISAppPoolManagedPipelineMode -eq $Null) { $HostIISAppPoolManagedPipelineMode = "Unknown"; }
if($HostIISAppPoolManagedRuntimeVersion -eq $Null) { $HostIISAppPoolManagedRuntimeVersion = "Unknown"; }
if($HostIISAppPoolQueueLength -eq $Null) { $HostIISAppPoolQueueLength = "-1"; }
if($HostIISAppPoolAutoStart -eq $Null) { $HostIISAppPoolAutoStart = "Unknown"; }
if($HostIISAppPoolState -eq $Null) { $HostIISAppPoolState = "Unknown"; }
if($HostIISAppPoolCpuAction -eq $Null) { $HostIISAppPoolCpuAction = "Unknown"; }
if($HostIISAppPoolCpuLimit -eq $Null) { $HostIISAppPoolCpuLimit = "Unknown"; }
if($HostIISAppPoolCpuResetInterval -eq $Null) { $HostIISAppPoolCpuResetInterval = "Unknown"; }
if($HostIISAppPoolRapidFailProtection -eq $Null) { $HostIISAppPoolRapidFailProtection = "Unknown"; }
if($HostIISAppPoolRapidFailProtectionInterval -eq $Null) { $HostIISAppPoolRapidFailProtectionInterval = "Unknown"; }
if($HostIISAppPoolRapidFailProtectionMaxCrashes -eq $Null) { $HostIISAppPoolRapidFailProtectionMaxCrashes = "-1"; }
if($HostIISAppPoolIdentityType -eq $Null) { $HostIISAppPoolIdentityType = "Unknown"; }
if($HostIISAppPoolIdleTimeout -eq $Null) { $HostIISAppPoolIdleTimeout = "Unknown"; }
if($HostIISAppPoolIdleTimeoutAction -eq $Null) { $HostIISAppPoolIdleTimeoutAction = "Unknown"; }
if($HostIISAppPoolShutdownTimeLimit -eq $Null) { $HostIISAppPoolShutdownTimeLimit = "Unknown"; }
if($HostIISAppPoolStartupTimeLimit -eq $Null) { $HostIISAppPoolStartupTimeLimit = "Unknown"; }
if($HostIISAppPoolMaxProcesses -eq $Null) { $HostIISAppPoolMaxProcesses = "-1"; }
if($HostIISAppPoolPingingEnabled -eq $Null) { $HostIISAppPoolPingingEnabled = "Unknown"; }
if($HostIISAppPoolPingInterval -eq $Null) { $HostIISAppPoolPingInterval = "Unknown"; }
if($HostIISAppPoolPingResponseTime -eq $Null) { $HostIISAppPoolPingResponseTime = "Unknown"; }
if($HostIISAppPoolLogEventOnProcessModel -eq $Null) { $HostIISAppPoolLogEventOnProcessModel = "Unknown"; }
if($HostIISAppPoolLogEventOnRecycle -eq $Null) { $HostIISAppPoolLogEventOnRecycle = "Unknown"; }
if($HostIISAppPoolRecycleMemory -eq $Null) { $HostIISAppPoolRecycleMemory = "-1"; }
if($HostIISAppPoolRecyclePrivateMemory -eq $Null) { $HostIISAppPoolRecyclePrivateMemory = "-1"; }
if($HostIISAppPoolRecycleRequests -eq $Null) { $HostIISAppPoolRecycleRequests = "-1"; }
if($HostIISAppPoolRecycleTime -eq $Null) { $HostIISAppPoolRecycleTime = "Unknown"; }
# Create Host IIS App Pool Json Data
$HostIISAppPoolJson = @{
ReportDate = "$VMReportDate"
HostID = "$VirtualMetricHostID"
HostName = "$VirtualMetricHostName"
FQDN = "$VirtualMetricHostFQDN"
Name = "$HostIISAppPoolName"
StartMode = "$HostIISAppPoolStartMode"
Enable32BitAppOnWin64 = "$HostIISAppPoolEnable32BitAppOnWin64"
ManagedPipelineMode = "$HostIISAppPoolManagedPipelineMode"
ManagedRuntimeVersion = "$HostIISAppPoolManagedRuntimeVersion"
QueueLength = "$HostIISAppPoolQueueLength"
AutoStart = "$HostIISAppPoolAutoStart"
State = "$HostIISAppPoolState"
CpuAction = "$HostIISAppPoolCpuAction"
CpuLimit = "$HostIISAppPoolCpuLimit"
CpuResetInterval = "$HostIISAppPoolCpuResetInterval"
RapidFailProtection = "$HostIISAppPoolRapidFailProtection"
RapidFailProtectionInterval = "$HostIISAppPoolRapidFailProtectionInterval"
RapidFailProtectionMaxCrashes = "$HostIISAppPoolRapidFailProtectionMaxCrashes"
IdentityType = "$HostIISAppPoolIdentityType"
IdleTimeout = "$HostIISAppPoolIdleTimeout"
IdleTimeoutAction = "$HostIISAppPoolIdleTimeoutAction"
ShutdownTimeLimit = "$HostIISAppPoolShutdownTimeLimit"
StartupTimeLimit = "$HostIISAppPoolStartupTimeLimit"
MaxProcesses = "$HostIISAppPoolMaxProcesses"
PingingEnabled = "$HostIISAppPoolPingingEnabled"
PingInterval = "$HostIISAppPoolPingInterval"
PingResponseTime = "$HostIISAppPoolPingResponseTime"
LogEventOnProcessModel = "$HostIISAppPoolLogEventOnProcessModel"
LogEventOnRecycle = "$HostIISAppPoolLogEventOnRecycle"
RecycleMemory = "$HostIISAppPoolRecycleMemory"
RecyclePrivateMemory = "$HostIISAppPoolRecyclePrivateMemory"
RecycleRequests = "$HostIISAppPoolRecycleRequests"
RecycleTime = "$HostIISAppPoolRecycleTime"
}| ConvertTo-Json -Compress
# Append to String Builder
$Null = $HostIISAppPoolsStringBuilder.Append("$HostIISAppPoolJson`r`n")
# Append to String Builder
$Null = $HostIISAppPoolsStringBuilder.Append(",")
}
# Append to String Builder
$Null = $HostIISAppPoolsStringBuilder.Append("{}]")
# Get Output String
$HostIISAppPoolsOutputString = $HostIISAppPoolsStringBuilder.ToString()
You will get all string output using with .ToString() for StringBuilder.
|