Remote Powershell to Exchange Server
$UserCredential
= Get-Credential
$Session =
New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://exchange server fqdn/PowerShell/
-Authentication Kerberos -Credential $UserCredential
Import-PSSession
$Session
Set-ADServerSettings
-ViewEntireForest $true
- Adding IP to anonymous relay
$RecvConn =
Get-ReceiveConnector "Relay Connector"
Get-Content .\IPList.txt | foreach {$RecvConn.RemoteIPRanges += "$_"}
Set-ReceiveConnector "Relay Connector" -RemoteIPRanges $RecvConn.RemoteIPRanges
Get-Content .\IPList.txt | foreach {$RecvConn.RemoteIPRanges += "$_"}
Set-ReceiveConnector "Relay Connector" -RemoteIPRanges $RecvConn.RemoteIPRanges
From <http://www.gabrielmatteson.com/index.php/howto-add-multiple-ips-to-exchange-receive-connector-cli/>
- Get-ReceiveConnector "ExchangeServer\RelayName" | Select -ExpandProperty RemoteIPRanges
$RecvConn
= Get-ReceiveConnector ExchangeServer\RelayName"
$RecvConn.RemoteIPRanges
+= "10.10.0.10"
Set-ReceiveConnector ExchangeServer\RelayName" -RemoteIPRanges
$RecvConn.RemoteIPRanges
- Account lockout
Get-Aduser
uateimcognos -Properties *|select name,SamAccountName,PasswordExpired,Enabled,
LockedOut, whenCreated,DisplayName,PasswordLastSet,LastLogonDate,
AccountLockoutTime, PasswordNeverExpires
Get-ADUser
gakumar -Properties * | Select-Object LockedOut
- Password Expiry
Get-ADUser Alice –Properties "DisplayName",
"msDS-UserPasswordExpiryTimeComputed" | Select-Object -Property
"Displayname",
@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}
- Service re-start on Exchange servers
Invoke-Command
-ComputerName ExchangeServer {Restart-Service MSExchangeDelivery,
MSExchangeSubmission, MSExchangeTransport -Force -PassThru}
- Service re-start on Exchange servers via input file
$servers
= Get-content D:\Temp\input.txt
Foreach($server
in $servers){Invoke-Command {Get-Service OR Restart-Service OR Stop-Service -ComputerName $server
MSExchangeDelivery,MSExchangeSubmission,MSExchangeTransport}}Format-Table
Name,Status,MachineName -AutoSize
- Scanning eventlog across multiple servers
Start-Transcript
$StartTime
= (Get-Date).AddDays(-7)
Get-Content
C:\tools\servers.txt | Foreach-Object{
Get-WinEvent -ComputerName $_ -MaxEvents
500 -FilterHashTable @{LogName='System'; ID=6008;
StartTime=$StartTime} | Select-Object
MachineName,TimeCreated,LevelDisplayName,ProviderName,ID,Message
}
- Stop services on multiple servers
'nodename','nodename','nodename' | foreach{Invoke-Command {Stop-Service MSExchangeHM,MSExchangeHMRecovery -Force
-PassThru} -computername $_} | Format-Table Name,Status,MachineName -AutoSize
- Start services on multiple servers
'nodename','nodename','nodename' | foreach{Invoke-Command {Start-Service MSExchangeHM,MSExchangeHMRecovery}
-computername $_} | Format-Table Name,Status,MachineName -AutoSize
- Disable service on multiple servers
'nodename','nodename','nodename' | foreach{Invoke-Command {Set-Service MSExchangeHMRecovery -StartupType
Disabled } -computername $_} | Format-Table Name,Status,MachineName -AutoSize
- Enable Automatic service on multiple servers
'nodename','nodename','nodename' | foreach{Invoke-Command {Set-Service MSExchangeHMRecovery -StartupType
Automatic} -computername $_} | Format-Table Name,Status,MachineName -AutoSize
- To get all the DB's mounted or not
Get-MailboxDatabase
-Status | ft Name, Server, Mounted
List of all databases
Get-MailboxDatabase
* -Status | Sort-Object -Descending {$_.databasesize} | ft server, name,
databasesize, *newmail* -AutoSize
Disconnected mailbox
Get-ExchangeServer |
Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object {
Get-MailboxStatistics -Server $_.Name | Where-Object {$_.DisconnectDate
–notlike ‘’}} | select displayname, database | export-csv c:mailboxes.csv
DL
get-content
c:\temp\dls.txt | Get-DistributionGroup | select-object Name,
AcceptMessagesOnlyFrom, RequireSenderAuthenticationEnabled | Export-Csv
c:\temp\dlexport.csv
Check if the user is enabled for
ActiveSync from EMC
Get-CASMailbox
-Identity alias | select DisplayName,PrimarySmtpAddress, ActiveSyncEnabled,
ActiveSyncAllowedDeviceIDs | format-list
Set-CASMailbox
-Identity alias -ActiveSyncEnabled $true
Get-ActiveSyncDeviceStatistics
-Mailbox alias
No comments:
Post a Comment