search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Powershell | No Comment | 1,031 views | 26/07/2015 17:32

These are IIS Website Client Access Information properties that you can get using CIM via PowerShell.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Get WebSites
$WebSites = Get-CimInstance -Namespace "root\MicrosoftIISv2" -ClassName "IIsWebServerSetting" -OperationTimeoutSec 15 -EA Stop
 
$WebSite = $WebSites[0];
 
# WebSite Client Access Information
[string]$WebSiteAccessExecute = $WebSite.AccessExecute
[string]$WebSiteAccessFlags = $WebSite.AccessFlags
[string]$WebSiteAccessNoPhysicalDir = $WebSite.AccessNoPhysicalDir
[string]$WebSiteAccessNoRemoteExecute = $WebSite.AccessNoRemoteExecute
[string]$WebSiteAccessNoRemoteRead = $WebSite.AccessNoRemoteRead
[string]$WebSiteAccessNoRemoteScript = $WebSite.AccessNoRemoteScript
[string]$WebSiteAccessNoRemoteWrite = $WebSite.AccessNoRemoteWrite
[string]$WebSiteAccessRead = $WebSite.AccessRead
[string]$WebSiteAccessScript = $WebSite.AccessScript
[string]$WebSiteAccessSource = $WebSite.AccessSource
[string]$WebSiteAccessSSL = $WebSite.AccessSSL
[string]$WebSiteAccessSSL128 = $WebSite.AccessSSL128
[string]$WebSiteAccessSSLFlags = $WebSite.AccessSSLFlags
[string]$WebSiteAccessSSLMapCert = $WebSite.AccessSSLMapCert
[string]$WebSiteAccessSSLNegotiateCert = $WebSite.AccessSSLNegotiateCert
[string]$WebSiteAccessSSLRequireCert = $WebSite.AccessSSLRequireCert
[string]$WebSiteAccessWrite = $WebSite.AccessWrite

You can find more properties in my blog.


Posted in Windows Powershell | No Comment | 2,010 views | 15/07/2015 12:53

There are many ways to validate an ip address in PowerShell. Common method is usually regex. But if you want to validate both IPv4 and IPv6 ip address in same Regex query, then life could be difficult. For example this is an query example for ipv4 and ipv6 validator regex:

'/^(?>(?>([a-f0-9]{1,4})(?>:(?1)){7}|(?!(?:.*[a-f0-9](?>:|$)){8,})((?1)(?>:(?1)){0,6})?::(?2)?)|(?>(?>(?1)(?>:(?1)){5}:|(?!(?:.*[a-f0-9]:){6,})(?3)?::(?>((?1)(?>:(?1)){0,4}):)?)?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?4)){3}))$/iD'

Personally I don’t want to deal with this kind of Regex queries. It’s hard to read, easy to make mistake. So let’s try another simple way, using [ipaddress] type.

1
2
3
4
5
6
7
8
9
10
11
PS C:\Users\Yusuf> [ipaddress]"10.10.10.0"
 
Address            : 657930
AddressFamily      : InterNetwork
ScopeId            :
IsIPv6Multicast    : False
IsIPv6LinkLocal    : False
IsIPv6SiteLocal    : False
IsIPv6Teredo       : False
IsIPv4MappedToIPv6 : False
IPAddressToString  : 10.10.10.0

As you see, it validates ipv4 address. So what about ipv6?

1
2
3
4
5
6
7
8
9
10
11
12
PS C:\Users\Yusuf> [ipaddress]"::1"
 
 
Address            :
AddressFamily      : InterNetworkV6
ScopeId            : 0
IsIPv6Multicast    : False
IsIPv6LinkLocal    : False
IsIPv6SiteLocal    : False
IsIPv6Teredo       : False
IsIPv4MappedToIPv6 : False
IPAddressToString  : ::1

Yes, it pretty works with ipv6 address. So what happens if I use a string?

1
2
3
4
5
6
7
PS C:\Users\Yusuf> [ipaddress]"::a333SSSSS"
Cannot convert value "::a333SSSSS" to type "System.Net.IPAddress". Error: "An invalid IP address was specified."
At line:1 char:1
+ [ipaddress]"::a333SSSSS"
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastParseTargetInvocation

So we can simply use something like this for validation:

1
2
3
4
if ("10.10.10.0" -as [ipaddress])
{
   write-output Validated!
}

Now you can use your expression between if blocks.


Posted in Windows Powershell | No Comment | 2,295 views | 12/07/2015 11:42

These are IIS Application Pool properties that you can get using CIM via PowerShell.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# WebSite AppPool Information
$WebSiteAppPools = Get-CimInstance -Namespace "root\MicrosoftIISv2" -ClassName "IIsApplicationPoolSetting" -OperationTimeoutSec 15 -EA Stop
 
$WebSiteAppPool = $WebSiteAppPools[0];
 
# IIS AppPool General Information
[string]$WebSiteAppPoolName = $WebSiteAppPool.Name
[string]$WebSiteAppPoolAppPoolAutoStart = $WebSiteAppPool.AppPoolAutoStart
[string]$WebSiteAppPoolAppPoolCommand = $WebSiteAppPool.AppPoolCommand
[string]$WebSiteAppPoolAppPoolIdentityType = $WebSiteAppPool.AppPoolIdentityType
[string]$WebSiteAppPoolAppPoolQueueLength = $WebSiteAppPool.AppPoolQueueLength
[string]$WebSiteAppPoolWAMUserName = $WebSiteAppPool.WAMUserName
[string]$WebSiteAppPoolWAMUserPass = $WebSiteAppPool.WAMUserPass
[string]$WebSiteAppPoolWin32Error = $WebSiteAppPool.Win32Error

You can find more properties in my blog.


Posted in Windows Powershell | No Comment | 3,174 views | 09/07/2015 18:05

You can use Compare-Object to compare two different arrays:

1
2
3
4
5
[array]$OldModules = @(1,2,3,4,5,6);
[array]$CurrentModules= @(1,2,4,5,6);
 
# Compare Modules
Compare-Object $OldModules $CurrentModules

If output of compare-object is null, it means two arrays are identical.


Posted in Windows Powershell | No Comment | 1,487 views | 07/07/2015 17:19

These are IIS Website properties that you can get using CIM via PowerShell.

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
# Get WebSites
$WebSites = Get-CimInstance -Namespace "root\MicrosoftIISv2" -ClassName "IIsWebServerSetting" -OperationTimeoutSec 15 -EA Stop
 
$WebSite = $WebSites[0];
 
# WebSite General Information
[string]$WebSiteId = $WebSite.Name.Split("/")[-1]
[string]$WebSiteName = $WebSite.ServerComment
[string]$WebSiteAppPool = $WebSite.AppPoolId
[string]$WebSiteMaxBandwidth = $WebSite.MaxBandwidth
[string]$WebSiteMaxConnections = $WebSite.MaxConnections
[string]$WebSiteConnectionTimeout = $WebSite.ConnectionTimeout
[string]$WebSiteCertCheckMode = $WebSite.CertCheckMode
[string]$WebSiteCGITimeout = $WebSite.CGITimeout
[string]$WebSiteCreateCGIWithNewConsole = $WebSite.CreateCGIWithNewConsole
[string]$WebSiteCreateProcessAsUser = $WebSite.CreateProcessAsUser
[string]$WebSiteClusterEnabled = $WebSite.ClusterEnabled
[string]$WebSiteContentIndexed = $WebSite.ContentIndexed
[string]$WebSiteDoStaticCompression = $WebSite.DoStaticCompression
[string]$WebSiteDoDynamicCompression = $WebSite.DoDynamicCompression
[string]$WebSiteFrontPageWeb = $WebSite.FrontPageWeb
[string]$WebSiteDisableSocketPooling = $WebSite.DisableSocketPooling
[string]$WebSiteDisableStaticFileCache = $WebSite.DisableStaticFileCache
[string]$WebSiteEnableReverseDns = $WebSite.EnableReverseDns
[string]$WebSiteShutdownTimeLimit = $WebSite.ShutdownTimeLimit
[string]$WebSiteSSIExecDisable = $WebSite.SSIExecDisable
[string]$WebSiteSSLAlwaysNegoClientCert = $WebSite.SSLAlwaysNegoClientCert
[string]$WebSiteUploadReadAheadSize = $WebSite.UploadReadAheadSize
[string]$WebSiteUseDigestSSP = $WebSite.UseDigestSSP

You can find more properties in my blog.


Posted in Windows Powershell | No Comment | 2,406 views | 30/06/2015 19:58

These are IIS Application Pool Rapid Fail Protection properties that you can get using CIM via PowerShell.

1
2
3
4
5
6
7
8
9
10
11
12
# WebSite AppPool Information
$WebSiteAppPools = Get-CimInstance -Namespace "root\MicrosoftIISv2" -ClassName "IIsApplicationPoolSetting" -OperationTimeoutSec 15 -EA Stop
 
$WebSiteAppPool = $WebSiteAppPools[0];
 
# IIS AppPool Rapid Fail Protection Information
[string]$WebSiteAppPoolRapidFailProtection = $WebSiteAppPool.RapidFailProtection
[string]$WebSiteAppPoolRapidFailProtectionInterval = $WebSiteAppPool.RapidFailProtectionInterval
[string]$WebSiteAppPoolRapidFailProtectionMaxCrashes = $WebSiteAppPool.RapidFailProtectionMaxCrashes
[string]$WebSiteAppPoolShutdownTimeLimit = $WebSiteAppPool.ShutdownTimeLimit
[string]$WebSiteAppPoolSMPAffinitized = $WebSiteAppPool.SMPAffinitized
[string]$WebSiteAppPoolSMPProcessorAffinityMask = $WebSiteAppPool.SMPProcessorAffinityMask

You can find more properties in my blog.


Posted in Windows Powershell | No Comment | 1,754 views | 19/06/2015 14:46

These are IIS Application Pool Recycling properties that you can get using CIM via PowerShell.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# WebSite AppPool Information
$WebSiteAppPools = Get-CimInstance -Namespace "root\MicrosoftIISv2" -ClassName "IIsApplicationPoolSetting" -OperationTimeoutSec 15 -EA Stop
 
$WebSiteAppPool = $WebSiteAppPools[0];
 
# IIS AppPool Recycling Information
[string]$WebSiteAppPoolAppPoolRecycleConfigChange = $WebSiteAppPool.AppPoolRecycleConfigChange
[string]$WebSiteAppPoolAppPoolRecycleIsapiUnhealthy = $WebSiteAppPool.AppPoolRecycleIsapiUnhealthy
[string]$WebSiteAppPoolAppPoolRecycleMemory = $WebSiteAppPool.AppPoolRecycleMemory
[string]$WebSiteAppPoolAppPoolRecycleOnDemand = $WebSiteAppPool.AppPoolRecycleOnDemand
[string]$WebSiteAppPoolAppPoolRecyclePrivateMemory = $WebSiteAppPool.AppPoolRecyclePrivateMemory
[string]$WebSiteAppPoolAppPoolRecycleRequests = $WebSiteAppPool.AppPoolRecycleRequests
[string]$WebSiteAppPoolAppPoolRecycleSchedule = $WebSiteAppPool.AppPoolRecycleSchedule
[string]$WebSiteAppPoolAppPoolRecycleTime = $WebSiteAppPool.AppPoolRecycleTime

You can find more properties in my blog.