Posted in Windows Powershell | No Comment | 1,508 views | 28/05/2015 10:54
Following script will get System Logs in last hour.
1
2
3
4
5
6
7
8
9
| # System Log Parameters
$SystemLogParameters = @{
LogName= "System"
EntryType= "Error","Warning"
After= (Get-Date).AddHours(-1)
}
# Get System Logs
Get-EventLog @SystemLogParameters |
# System Log Parameters
$SystemLogParameters = @{
LogName= "System"
EntryType= "Error","Warning"
After= (Get-Date).AddHours(-1)
}
# Get System Logs
Get-EventLog @SystemLogParameters
You can set scope by changing EntryType parameter.
Posted in Windows Powershell | No Comment | 1,584 views | 28/05/2015 10:51
Following script will get Application Logs in last hour with “vmic*” source logs.
1
2
3
4
5
6
7
8
9
| # Application Log Parameters
$ApplicationLogParameters = @{
LogName= "Application"
EntryType= "Error","Warning"
After= (Get-Date).AddHours(-1)
}
# Get Application Logs
Get-EventLog @ApplicationLogParameters -Source vmic* |
# Application Log Parameters
$ApplicationLogParameters = @{
LogName= "Application"
EntryType= "Error","Warning"
After= (Get-Date).AddHours(-1)
}
# Get Application Logs
Get-EventLog @ApplicationLogParameters -Source vmic*
You can set scope by changing EntryType parameter.
Posted in Windows Powershell | 4 Comments | 7,321 views | 28/05/2015 10:47
Following creates a new event log folder called “yusufozturk” in your Application Log Folder.
1
2
3
4
5
| # Create Event Log
New-EventLog -LogName "yusufozturk" -Source "Hyper-V" -EA SilentlyContinue
# Limit Event Log Properties
Limit-EventLog -LogName "yusufozturk" -OverflowAction "OverWriteAsNeeded" -MaximumSize 100MB -EA SilentlyContinue |
# Create Event Log
New-EventLog -LogName "yusufozturk" -Source "Hyper-V" -EA SilentlyContinue
# Limit Event Log Properties
Limit-EventLog -LogName "yusufozturk" -OverflowAction "OverWriteAsNeeded" -MaximumSize 100MB -EA SilentlyContinue
As you see, you can also set OverFlowAction and MaximumSize.
Posted in Windows Powershell | No Comment | 2,806 views | 27/05/2015 18:00
As you know, LoadWithPartialName is now deprecated. So you need to change your codes.
You should use Add-Type instead of LoadWithPartialName. This is example alternative for that:
Add-Type -Path "C:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll" |
Add-Type -Path "C:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll"
That will load DLL into PowerShell session. So you have to specify full path now.
Then you can use it like:
New-Object Microsoft.Web.Administration.ServerManager |
New-Object Microsoft.Web.Administration.ServerManager
Now you can start exploring IIS using with Add-Type :)
Posted in Windows Powershell | No Comment | 1,194 views | 16/05/2015 13:48
These are IIS Application Pool Limits 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 Limits Information
[string]$WebSiteAppPoolAppPoolState = $WebSiteAppPool.AppPoolState
[string]$WebSiteAppPoolCPUAction = $WebSiteAppPool.CPUAction
[string]$WebSiteAppPoolCPULimit = $WebSiteAppPool.CPULimit
[string]$WebSiteAppPoolCPUResetInterval = $WebSiteAppPool.CPUResetInterval
[string]$WebSiteAppPoolDisallowOverlappingRotation = $WebSiteAppPool.DisallowOverlappingRotation
[string]$WebSiteAppPoolDisallowRotationOnConfigChange = $WebSiteAppPool.DisallowRotationOnConfigChange |
# WebSite AppPool Information
$WebSiteAppPools = Get-CimInstance -Namespace "root\MicrosoftIISv2" -ClassName "IIsApplicationPoolSetting" -OperationTimeoutSec 15 -EA Stop
$WebSiteAppPool = $WebSiteAppPools[0];
# IIS AppPool Limits Information
[string]$WebSiteAppPoolAppPoolState = $WebSiteAppPool.AppPoolState
[string]$WebSiteAppPoolCPUAction = $WebSiteAppPool.CPUAction
[string]$WebSiteAppPoolCPULimit = $WebSiteAppPool.CPULimit
[string]$WebSiteAppPoolCPUResetInterval = $WebSiteAppPool.CPUResetInterval
[string]$WebSiteAppPoolDisallowOverlappingRotation = $WebSiteAppPool.DisallowOverlappingRotation
[string]$WebSiteAppPoolDisallowRotationOnConfigChange = $WebSiteAppPool.DisallowRotationOnConfigChange
You can find more properties in my blog.
Posted in Windows Powershell | No Comment | 1,393 views | 04/05/2015 17:23
These are IIS Website Logging 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
30
31
32
33
34
35
| # Get WebSites
$WebSites = Get-CimInstance -Namespace "root\MicrosoftIISv2" -ClassName "IIsWebServerSetting" -OperationTimeoutSec 15 -EA Stop
$WebSite = $WebSites[0];
# WebSite Log Information
[string]$WebSiteLogFormat = $WebSite.LogType
[string]$WebSiteLogDirectory = $WebSite.LogFileDirectory
[string]$WebSiteLogPeriod = $WebSite.LogFilePeriod
[string]$WebSiteLogTruncateSize = $WebSite.LogFileTruncateSize
[string]$WebSiteLogLocalTimeRollover = $WebSite.LogFileLocaltimeRollover
[string]$WebSiteLogState = $WebSite.DontLog
[string]$WebSiteLogExtFileBytesRecv = $WebSite.LogExtFileBytesRecv
[string]$WebSiteLogExtFileBytesSent = $WebSite.LogExtFileBytesSent
[string]$WebSiteLogExtFileClientIp = $WebSite.LogExtFileClientIp
[string]$WebSiteLogExtFileComputerName = $WebSite.LogExtFileComputerName
[string]$WebSiteLogExtFileCookie = $WebSite.LogExtFileCookie
[string]$WebSiteLogExtFileDate = $WebSite.LogExtFileDate
[string]$WebSiteLogExtFileFlags = $WebSite.LogExtFileFlags
[string]$WebSiteLogExtFileHost = $WebSite.LogExtFileHost
[string]$WebSiteLogExtFileHttpStatus = $WebSite.LogExtFileHttpStatus
[string]$WebSiteLogExtFileHttpSubStatus = $WebSite.LogExtFileHttpSubStatus
[string]$WebSiteLogExtFileMethod = $WebSite.LogExtFileMethod
[string]$WebSiteLogExtFileProtocolVersion = $WebSite.LogExtFileProtocolVersion
[string]$WebSiteLogExtFileReferer = $WebSite.LogExtFileReferer
[string]$WebSiteLogExtFileServerIp = $WebSite.LogExtFileServerIp
[string]$WebSiteLogExtFileServerPort = $WebSite.LogExtFileServerPort
[string]$WebSiteLogExtFileSiteName = $WebSite.LogExtFileSiteName
[string]$WebSiteLogExtFileTime = $WebSite.LogExtFileTime
[string]$WebSiteLogExtFileTimeTaken = $WebSite.LogExtFileTimeTaken
[string]$WebSiteLogExtFileUriQuery = $WebSite.LogExtFileUriQuery
[string]$WebSiteLogExtFileUriStem = $WebSite.LogExtFileUriStem
[string]$WebSiteLogExtFileUserAgent = $WebSite.LogExtFileUserAgent
[string]$WebSiteLogExtFileUserName = $WebSite.LogExtFileUserName
[string]$WebSiteLogExtFileWin32Status = $WebSite.LogExtFileWin32Status |
# Get WebSites
$WebSites = Get-CimInstance -Namespace "root\MicrosoftIISv2" -ClassName "IIsWebServerSetting" -OperationTimeoutSec 15 -EA Stop
$WebSite = $WebSites[0];
# WebSite Log Information
[string]$WebSiteLogFormat = $WebSite.LogType
[string]$WebSiteLogDirectory = $WebSite.LogFileDirectory
[string]$WebSiteLogPeriod = $WebSite.LogFilePeriod
[string]$WebSiteLogTruncateSize = $WebSite.LogFileTruncateSize
[string]$WebSiteLogLocalTimeRollover = $WebSite.LogFileLocaltimeRollover
[string]$WebSiteLogState = $WebSite.DontLog
[string]$WebSiteLogExtFileBytesRecv = $WebSite.LogExtFileBytesRecv
[string]$WebSiteLogExtFileBytesSent = $WebSite.LogExtFileBytesSent
[string]$WebSiteLogExtFileClientIp = $WebSite.LogExtFileClientIp
[string]$WebSiteLogExtFileComputerName = $WebSite.LogExtFileComputerName
[string]$WebSiteLogExtFileCookie = $WebSite.LogExtFileCookie
[string]$WebSiteLogExtFileDate = $WebSite.LogExtFileDate
[string]$WebSiteLogExtFileFlags = $WebSite.LogExtFileFlags
[string]$WebSiteLogExtFileHost = $WebSite.LogExtFileHost
[string]$WebSiteLogExtFileHttpStatus = $WebSite.LogExtFileHttpStatus
[string]$WebSiteLogExtFileHttpSubStatus = $WebSite.LogExtFileHttpSubStatus
[string]$WebSiteLogExtFileMethod = $WebSite.LogExtFileMethod
[string]$WebSiteLogExtFileProtocolVersion = $WebSite.LogExtFileProtocolVersion
[string]$WebSiteLogExtFileReferer = $WebSite.LogExtFileReferer
[string]$WebSiteLogExtFileServerIp = $WebSite.LogExtFileServerIp
[string]$WebSiteLogExtFileServerPort = $WebSite.LogExtFileServerPort
[string]$WebSiteLogExtFileSiteName = $WebSite.LogExtFileSiteName
[string]$WebSiteLogExtFileTime = $WebSite.LogExtFileTime
[string]$WebSiteLogExtFileTimeTaken = $WebSite.LogExtFileTimeTaken
[string]$WebSiteLogExtFileUriQuery = $WebSite.LogExtFileUriQuery
[string]$WebSiteLogExtFileUriStem = $WebSite.LogExtFileUriStem
[string]$WebSiteLogExtFileUserAgent = $WebSite.LogExtFileUserAgent
[string]$WebSiteLogExtFileUserName = $WebSite.LogExtFileUserName
[string]$WebSiteLogExtFileWin32Status = $WebSite.LogExtFileWin32Status
You can find more properties in my blog.
|