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,487 views | 16/08/2015 17:30

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

1
2
3
4
5
6
7
8
9
10
11
12
# Get WebSites
$WebSites = Get-CimInstance -Namespace "root\MicrosoftIISv2" -ClassName "IIsWebServerSetting" -OperationTimeoutSec 15 -EA Stop
 
$WebSite = $WebSites[0];
 
# WebSite Directory Browsing Information
[string]$WebSiteEnableDirBrowsing = $WebSite.EnableDirBrowsing
[string]$WebSiteDirBrowseShowDate = $WebSite.DirBrowseShowDate
[string]$WebSiteDirBrowseShowExtension = $WebSite.DirBrowseShowExtension
[string]$WebSiteDirBrowseShowLongDate = $WebSite.DirBrowseShowLongDate
[string]$WebSiteDirBrowseShowSize = $WebSite.DirBrowseShowSize
[string]$WebSiteDirBrowseShowTime = $WebSite.DirBrowseShowTime

You can find more properties in my blog.


Posted in Windows Powershell | No Comment | 1,095 views | 15/08/2015 17:55

These are IIS Application Pool Periodic Restart 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 Periodic Restart Information
[string]$WebSiteAppPoolPeriodicRestartMemory = $WebSiteAppPool.PeriodicRestartMemory
[string]$WebSiteAppPoolPeriodicRestartPrivateMemory = $WebSiteAppPool.PeriodicRestartPrivateMemory
[string]$WebSiteAppPoolPeriodicRestartRequests = $WebSiteAppPool.PeriodicRestartRequests
[string]$WebSiteAppPoolPeriodicRestartSchedule = $WebSiteAppPool.PeriodicRestartSchedule
[string]$WebSiteAppPoolPeriodicRestartTime = $WebSiteAppPool.PeriodicRestartTime
[string]$WebSiteAppPoolPingingEnabled = $WebSiteAppPool.PingingEnabled
[string]$WebSiteAppPoolPingInterval = $WebSiteAppPool.PingInterval
[string]$WebSiteAppPoolPingResponseTime = $WebSiteAppPool.PingResponseTime

You can find more properties in my blog.


Posted in Windows Powershell | No Comment | 1,484 views | 14/08/2015 17:26

These are IIS Website Binding 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 Binding Information
$WebSiteBinding = $WebSite.ServerBindings[0]
[string]$WebSiteBindingHostname = $WebSiteBinding.Hostname
[string]$WebSiteBindingIP = $WebSiteBinding.IP
[string]$WebSiteBindingPort = $WebSiteBinding.Port

You can find more properties in my blog.


Posted in Windows Powershell | No Comment | 1,128 views | 28/07/2015 17:51

These are IIS Application Pool Process 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 Process Information
[string]$WebSiteAppPoolEnable32BitAppOnWin64 = $WebSiteAppPool.Enable32BitAppOnWin64
[string]$WebSiteAppPoolIdleTimeout = $WebSiteAppPool.IdleTimeout
[string]$WebSiteAppPoolLoadBalancerCapabilities = $WebSiteAppPool.LoadBalancerCapabilities
[string]$WebSiteAppPoolLogEventOnRecycle = $WebSiteAppPool.LogEventOnRecycle
[string]$WebSiteAppPoolLogonMethod = $WebSiteAppPool.LogonMethod
[string]$WebSiteAppPoolManagedPipelineMode = $WebSiteAppPool.ManagedPipelineMode
[string]$WebSiteAppPoolManagedRuntimeVersion = $WebSiteAppPool.ManagedRuntimeVersion
[string]$WebSiteAppPoolMaxProcesses = $WebSiteAppPool.MaxProcesses

You can find more properties in my blog.


Posted in Windows Powershell | No Comment | 1,026 views | 27/07/2015 17:36

These are IIS Website Authentication 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
# Get WebSites
$WebSites = Get-CimInstance -Namespace "root\MicrosoftIISv2" -ClassName "IIsWebServerSetting" -OperationTimeoutSec 15 -EA Stop
 
$WebSite = $WebSites[0];
 
# WebSite Authentication Information
[string]$WebSiteAuthAdvNotifyDisable = $WebSite.AuthAdvNotifyDisable
[string]$WebSiteAuthAnonymous = $WebSite.AuthAnonymous
[string]$WebSiteAuthBasic = $WebSite.AuthBasic
[string]$WebSiteAuthChangeDisable = $WebSite.AuthChangeDisable
[string]$WebSiteAuthChangeUnsecure = $WebSite.AuthChangeUnsecure
[string]$WebSiteAuthFlags = $WebSite.AuthFlags
[string]$WebSiteAuthMD5 = $WebSite.AuthMD5
[string]$WebSiteAuthNTLM = $WebSite.AuthNTLM
[string]$WebSiteAuthPassport = $WebSite.AuthPassport
[string]$WebSiteAuthPersistence = $WebSite.AuthPersistence
[string]$WebSiteAuthPersistSingleRequest = $WebSite.AuthPersistSingleRequest

You can find more properties in my blog.


Posted in Windows Powershell | No Comment | 1,029 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 | 1,987 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.