Skip to content

Commit 0842726

Browse files
committed
add
1 parent 18fd8dc commit 0842726

10 files changed

+29216
-334
lines changed

bat/vmware-batch.bat

+348-332
Large diffs are not rendered by default.

powershell/exchange/ADDS_Inventory_V2.ps1

+16,523
Large diffs are not rendered by default.

powershell/exchange/Get-ExchangeEnvironmentReport.ps1

+1,454
Large diffs are not rendered by default.

powershell/exchange/Get-ExchangeTracking.ps1

+4,086
Large diffs are not rendered by default.

powershell/exchange/HealthChecker.ps1

+5,839
Large diffs are not rendered by default.

powershell/exchange/MessageTrackingLogGUI.ps1

+507
Large diffs are not rendered by default.

powershell/exchange/Set-Webserver.ps1

+252
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
<#
2+
.SYNOPSIS
3+
Configures IIS log file settings
4+
5+
Thomas Stensitzki
6+
7+
THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE
8+
RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
9+
10+
Version 1.1, 2016-07-28
11+
12+
Ideas, comments and suggestions to [email protected]
13+
14+
Some parts (c) Michel de Rooij, [email protected]
15+
16+
.LINK
17+
http://www.granikos.eu/en/scripts
18+
19+
20+
.DESCRIPTION
21+
This script reconfigures the IIS log folder to target a different folder besides the
22+
default C:\inetpub\logs folder. Additionally the log settings can be adjusted as well.
23+
The script changes the default log file location and settings on a server level. By
24+
default the settings are inherited by websites. If manual changes have been made on
25+
a webite level, not all settings will be inherited.
26+
27+
.NOTES
28+
Requirements
29+
- Windows Server 2008 R2 SP1, Windows Server 2012 or Windows Server 2012 R2
30+
31+
32+
Revision History
33+
--------------------------------------------------------------------------------
34+
1.0 Initial community release
35+
1.1 PowerShell hygiene applied, some typo fixes
36+
37+
38+
.PARAMETER LogFolderPath
39+
New IIS log folder path, i.e. D:\IISLogs. Default is an empty string.
40+
41+
.PARAMETER LogFilePeriod
42+
Log file period (interval), Hourly|Daily|Weekly|Monthly|MaxSize
43+
MaxSize configuration not yet implemented
44+
45+
.PARAMETER LocalTimeRollover
46+
Boolean parameter indicating, if the local time shall be used for filenames and rollover
47+
Default $FALSE
48+
49+
.EXAMPLE
50+
Change the IIS log file location to D:\IISLogs
51+
.\Set-Webserver.ps1 -LogFolderPath D:\IISLogs
52+
53+
.EXAMPLE
54+
Change the IIS log period to an hourly period
55+
.\Set-Webserver.ps1 -LogFilePeriod Hourly
56+
57+
.EXAMPLE
58+
Use the local time for filenames and log file rollover
59+
.\Set-Webserver.ps1 -LocalTimeRollover $true
60+
61+
#>
62+
63+
64+
Param(
65+
[parameter(Position=0,Mandatory=$false,ValueFromPipeline=$false,HelpMessage='New IIS log folder path, i.e. D:\IISLogs')]
66+
[string]$LogFolderPath = '',
67+
[parameter(Position=1,Mandatory=$false,ValueFromPipeline=$false,HelpMessage='Log file period (Hourly|Daily|Weekly|Monthly|MaxSize)')]
68+
[string]$LogFilePeriod = '',
69+
[parameter(Position=2,Mandatory=$false,ValueFromPipeline=$false,HelpMessage='$true/$false indicating, if the local time shall be used for filenames and rollover')]
70+
[bool]$LocalTimeRollover=$false
71+
)
72+
73+
process{
74+
75+
# log file property settings
76+
$lfpDirectory = 'directory'
77+
$lfpPeriod = 'period'
78+
$lfpLocalTimeRollover = 'localTimeRollover'
79+
80+
# Check if folder exists, otherwise create folder
81+
function Create-Folder
82+
{
83+
param
84+
(
85+
[string]
86+
$folderPath
87+
)
88+
89+
Write-Verbose "Evaluating IIS folder path: $folderPath"
90+
91+
if(-not ($folderPath -eq ''))
92+
{
93+
if(-not (Test-Path $folderPath))
94+
{
95+
Write-Host "Creating IIS log folder path: $folderPath"
96+
97+
New-Item -Path $folderPath -ItemType directory | Out-Null
98+
}
99+
else
100+
{
101+
Write-Host "Folder $folderPath already exsists"
102+
}
103+
}
104+
}
105+
106+
# Change IIS log file setting
107+
function ChangeIisLogSetting
108+
{
109+
param
110+
(
111+
[string]
112+
$settingName,
113+
114+
[string]
115+
$settingValue
116+
)
117+
118+
try
119+
{
120+
Write-Verbose "Configuring IIS log setting $settingsName to value $settingsValue"
121+
122+
$logConfig = @{$settingName=$settingValue}
123+
124+
Set-WebConfigurationProperty 'system.applicationHost/sites/siteDefaults' -Name logFile -Value $logConfig
125+
}
126+
catch [system.exception]
127+
{
128+
Write-Host 'An error occured while trying to write IIS settings. Please check permissions of your account and ensure that PowerShell is running from an elevated prompt.' -ForegroundColor Red
129+
}
130+
}
131+
132+
# Change IIS default log location and other IIS log settings
133+
function ChangeIisLogPath
134+
{
135+
param
136+
(
137+
[string]
138+
$folderPath
139+
)
140+
141+
Write-Verbose "IIS Log Folder Path to configure: $folderPath"
142+
Write-Host "Configuring IIS default log location to '$folderPath'"
143+
144+
if(Test-Path $folderPath)
145+
{
146+
ChangeIisLogSetting $lfpDirectory $folderPath
147+
}
148+
else
149+
{
150+
Write-Host "New IIS log folder $folderPath does not exist. IIS log file folder configuration has not been changed" -ForegroundColor Red
151+
}
152+
}
153+
154+
# Change IIS log period
155+
function ChangeIisLogPeriod
156+
{
157+
param
158+
(
159+
[string]
160+
$logPeriod
161+
)
162+
163+
if($AllowedLogFilePeriod -contains $logPeriod)
164+
{
165+
Write-Verbose "Changing IIS log periog to: $logPeriod"
166+
167+
ChangeIisLogSetting $lfpPeriod $logPeriod
168+
}
169+
}
170+
171+
# Change IIS LocalTimeRollover setting
172+
function ChangeLocalTimeRollover
173+
{
174+
param
175+
(
176+
[bool]
177+
$logLocalTimeRollover
178+
)
179+
180+
Write-Verbose "Changing IIS log local time rollover to: $logLocalTimeRollover"
181+
182+
ChangeIisLogSetting $lfpLocalTimeRollover $logLocalTimeRollover
183+
}
184+
185+
186+
function CheckWindowsFeature
187+
{
188+
param
189+
(
190+
[string]
191+
$MajorOSVersion
192+
)
193+
194+
$featureInstalled = $false
195+
196+
If ($MajorOSVersion -eq '6.1')
197+
{
198+
Import-Module ServerManager
199+
If(!(Get-Module ServerManager))
200+
{
201+
Write-Error 'Problem loading ServerManager module'
202+
Exit 'ServerManager module could not be loaded!'
203+
}
204+
}
205+
206+
Write-Verbose "Checking, if Windows Feature 'Web-Server' is installed"
207+
208+
$feature = Get-WindowsFeature Web-Server
209+
$featureInstalled = [bool]($feature.Installed)
210+
211+
Write-Verbose "Feature 'Web-Server' installed: $featureInstalled"
212+
213+
return( $featureInstalled )
214+
}
215+
216+
## Main
217+
Write-Verbose 'Script started'
218+
219+
$MajorOSVersion= [string](Get-WmiObject Win32_OperatingSystem | Select-Object Version | Select-Object @{n='Major';e={($_.Version.Split('.')[0]+'.'+$_.Version.Split('.')[1])}}).Major
220+
$AllowedLogFilePeriod = @('Hourly','Daily','Weekly','Monthly') # MaxSize not yet implemented
221+
222+
if( CheckWindowsFeature($MajorOSVersion) )
223+
{
224+
225+
Write-Verbose 'Configuring IIS log file settings'
226+
227+
if($LogFolderPath -ne '')
228+
{
229+
# Create IIS Log File Folder, independent from server role
230+
Create-Folder $LogFolderPath
231+
232+
#Change log file settings
233+
ChangeIisLogPath $LogFolderPath $LogFilePeriod
234+
}
235+
236+
if($LogFilePeriod -ne '')
237+
{
238+
ChangeIisLogPeriod $LogFilePeriod
239+
}
240+
241+
if($LocalTimeRollover -ne $null)
242+
{
243+
ChangeLocalTimeRollover $LocalTimeRollover
244+
}
245+
}
246+
else
247+
{
248+
Write-Host 'IIS is currently not installed. Either add the windows feature manually or install Exchange first and adjust the IIS log file location afterwards.' -ForegroundColor Red
249+
}
250+
251+
Write-Verbose 'Script ended'
252+
} #Process
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
. 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'
3+
Connect-ExchangeServer -auto
4+
5+
$LogFile="C:\add_ad_user_mail-$((Get-Date).ToString('yyyy-MM-dd')).log"
6+
Start-Transcript -path $LogFile -append
7+
8+
Write-Output "[$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss.fZ'))] [Start]"
9+
10+
Import-module activedirectory
11+
# $since=(Get-Date).AddDays(-4).ToUniversalTime().ToString('yyyyMMddHHmmss.fZ')
12+
$since=(Get-Date).AddMinutes(-20).ToUniversalTime().ToString('yyyyMMddHHmmss.fZ')
13+
$users=Get-ADUser -LDAPfilter "(&(objectCategory=person)(objectClass=user)(Name=*)(!(!UserPrincipalName=*))(whenCreated>=$since))" -searchBase 'CN=Users,DC=bloks,DC=local'
14+
15+
foreach($user in $users)
16+
{
17+
Write-Output "[$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss.fZ'))] [User] $($user.SamAccountName)"
18+
if (Get-Mailbox -Identity $user.SamAccountName 2>$null)
19+
{
20+
Write-Output "[$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss.fZ'))] [User] $($user.SamAccountName): It's alive"
21+
}
22+
else
23+
{
24+
Write-Output "[$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss.fZ'))] [User] $($user.SamAccountName): enable mailbox"
25+
Enable-Mailbox -Identity $user.SamAccountName
26+
}
27+
}
28+
29+
Write-Output "[$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss.fZ'))] [End]"
30+
31+
Stop-Transcript

0 commit comments

Comments
 (0)