Tuesday, 22 November 2011
Server 2008 - Remotely adding/removing users from Groups
runas /user:domain\username "psexec \\server net localgroup test domain\username {/add or /delete}"
Monday, 14 November 2011
Remotely installing SNMP on Server 2008
1. On one server, install SNMP 2008 (C:\ocsetup SNMP), configure the service and export HKLM\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ to C:\snmp.reg
2. Create a batch file that will a). import the key exported from step 1. b). delete the 1 value which needs to be removed to allow 'Any host' to connect to the SNMP service.
reg import C:\snmp\snmp.reg
reg delete HKLM\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers /v 1 /f
3. Copy these files to all of the servers via this script (make sure to create the C:\computers.txt and populate):
Const ForReading = 1
Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\computers.txt")
Do Until objFile.AtEndOfStream
strComputer = objFile.ReadLine
strRemoteFile = "\\" & strComputer & "\C$\snmp.reg"
objFSO.CopyFile "C:\snmp\snmp.reg", strRemoteFile, OverwriteExisting
Loop
4. Use psexec to execute the snmp.bat on each server via:
C:\runas /user:domain\username "psexec \\server\ C:\snmp.bat"
5. Use snmpwalk from this page and run
Steps 4 & 6 can be improved by getting the @file command with psexec, but since it's paired with runas it might be tricky to get that to work.
2. Create a batch file that will a). import the key exported from step 1. b). delete the 1 value which needs to be removed to allow 'Any host' to connect to the SNMP service.
reg import C:\snmp\snmp.reg
reg delete HKLM\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers /v 1 /f
3. Copy these files to all of the servers via this script (make sure to create the C:\computers.txt and populate):
Const ForReading = 1
Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\computers.txt")
Do Until objFile.AtEndOfStream
strComputer = objFile.ReadLine
strRemoteFile = "\\" & strComputer & "\C$\snmp.reg"
objFSO.CopyFile "C:\snmp\snmp.reg", strRemoteFile, OverwriteExisting
Loop
4. Use psexec to execute the snmp.bat on each server via:
C:\runas /user:domain\username "psexec \\server\ C:\snmp.bat"
5. Use snmpwalk from this page and run
snmpwalk -v 1 -c community-here 127.0.0.1
6. Remove all of the files using:
Const ForReading = 1
Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\computers.txt")
Do Until objFile.AtEndOfStream
strComputer = objFile.ReadLine
strRemoteFile = "\\" & strComputer & "\C$\snmp.reg"
objFSO.DeleteFile strRemoteFile
Loop
Steps 4 & 6 can be improved by getting the @file command with psexec, but since it's paired with runas it might be tricky to get that to work.
Thursday, 27 October 2011
Replacing Mailbox Display Name with Simple Display Name
Set-RemoteDomain "Default" -UseSimpleDisplayName $true
Requires SP1 RU4
Requires SP1 RU4
Moving Mailboxes Across Forests
- $c = Get-Credential <-- Enter your account for X domain
- $t = Get-Credential <-- Enter your account for Y domain
- move-mailbox -TargetDatabase "servername\storage group\database" -Identity 'mailbox name' -GlobalCatalog servername -SourceForestGlobalCatalog servername -NTAccountOU "OU=XXXX,DC=domain,DC=com" -SourceForestCredential $c -TargetForestCredential $t
Friday, 14 October 2011
Exchange 2007 - Bulk Create Groups
- import-csv "C:\filename.csv" | % {New-DistributionGroup -Name $_.Groupname -DisplayName $_.Displayname -OrganizationalUnit "domain.local/groups/distribution" -SamAccountName $_.SamName -Type Distribution}
- Make sure your spreadsheet columns match the names above so that:
- Groupname = The name you want the distribution group to have in Exchange (NOT the display name!)
- SamName = Specify the same name as the Group Name. It's for AD.
- Displayname = The display name (the one that contains #)
- import-csv "C:\filename.csv" | % {Set-DistributionGroup -identity $_.Groupname -EmailAddressPolicyEnabled $false -PrimarySmtpAddress $_.email -RequireSenderAuthenticationEnabled $false}
- Make sure your spreadsheet columns match the names above so that:
- Groupname = The name of the group you want to change
- Email = The email address you want to specify (if different than default)
- If no groups need their email address specified, then run this command instead:
- import-csv "C:\filename.csv" | % {Set-DistributionGroup -identity $_.Groupname -RequireSenderAuthenticationEnabled $false}
Exchange 2007 - Clear Transaction Logs
- Run NTBackup and start an incremental backup on the affected storage group immediately
- Check the amount of space remaining and how quickly the drive is filling up. If it looks like NTBackup won't be able to complete before the drive fills up (the DB's will dismount) then proceed to performing the step below.
- On the Active mailbox server, run the following command in Powershell - make sure to update the path below accordingly
- eseutil /MK "H:\database\Third Storage Group\E02.chk"
- The output will have a Checkpoint entry that looks like this:
Checkpoint: (0x35B88,80,0) - 35B88 is the last 5 characters of the last transaction log that is needed by the DB. So if there are logs older than this file (35B87, 35B86, etc...) then those logs have been committed by the Database and are no longer needed. Ensure that you sort the view in Explorer by modified, since sorting by Name will not sort them properly.
- You can proceed to move those logs elsewhere to free up the space, and then run an Incremental Backup to purge the remaining logs.
Exchange 2007 - Message Tracking
Search by IP:
- get-messagetrackinglog -ResultSize unlimited -Start "9/3/2010 12:00:00 AM" -End "9/5/2010 11:59:00 PM" | where {$_.ClientIP -eq "xxx.xxx.xxx.xxx"} | fl ClientIP
- get-messagetrackinglog -Sender "email@domain.com" -EventID "SEND" -Server servername -Start "2011/08/01 12:00:00 AM" -End "2011/10/13 12:00:00 AM" -ResultSize Unlimited | where {[string]$_.recipients -like "*@*"} |select Sender,@{Name="Recipients";Expression={$_.recipients}},MessageSubject,MessageId,Timestamp,ConnectorId | export-csv C:\filename.csv
Exchange 2007 - Mailbox Statistics
- Get-MailboxStatistics -Server Servername | Sort -Property DisplayName | ft DisplayName, @{expression={$_.totalitemsize.value.ToMB()};label="Mailbox Size(MB)"}, itemcount, lastlogontime, lastlogofftime,lastloggedonuseraccount
- get-mailbox | Get-MailboxStatistics | Select @{n="DisplayName";e={$_.DisplayName}}, StorageGroupName,@{e={$_.TotalDeletedItemSize.Value.ToMB()};n="TotalDeletedItemsSize(MB)"}, DeletedItemCount, @{e={$_.TotalItemSize.Value.ToMB()};n="TotalItemSize(MB)"}, ItemCount, StorageLimitStatus | Sort-Object "TotalItemSize(MB)" | ft
- get-mailbox | Get-MailboxStatistics | where-object {$_.StorageLimitStatus -eq "NoChecking"} | Select @{n="DisplayName";e={$_.DisplayName}}, StorageGroupName,@{e={$_.TotalDeletedItemSize.Value.ToMB()};n="TotalDeletedItemsSize(MB)"}, DeletedItemCount, @{e={$_.TotalItemSize.Value.ToMB()};n="TotalItemSize(MB)"}, ItemCount, StorageLimitStatus | Sort-Object "TotalItemSize(MB)" | ft
Subscribe to:
Posts (Atom)