Member_2_6474242
asked on
script to get queue statistics
I have used the below to try and create the same script
$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://xxx.com/PowerShell/ -Authentication Kerberos
Import-PSSession $s
Add-PSSnapin Microsoft.Exchange.Managem ent.PowerS hell.E2010
. $env:ExchangeInstallPath\b in\RemoteE xchange.ps 1
Connect-ExchangeServer -auto
$threshold = 10
$filename = "c:\Temp\QueueStats.txt"
Start-Sleep -s 10
if (Get-ExchangeServer | Where { $_.Name -eq "Mail" } | get-queue | Where-Object { $_.MessageCount -gt $threshold })
{
Get-ExchangeServer | Where { $_.Name -eq "Mail" } | get-queue | Where-Object { $_.MessageCount -gt $threshold } | Format-Table -Wrap -AutoSize | out-file -filepath c:\Temp\QueueStats.txt
Start-Sleep -s 10
$smtpServer = "10.0.1.6"
Write-Host "Connecting to $smtpServer"
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($filen ame)
$smtp = new-object Net.Mail.SmtpClient($smtpS erver)
$msg.From = "rsharma@xxx.com"
$msg.To.Add("rsharma@xxx.c om")
$msg.To.Add("rprasad@xxx.c om")
$msg.Subject = "EXCHANGE SERVER - CAS THRESHOLD ALERT!!!"
$msg.Body = "Please see attached queue log file for queue information. "
$msg.Attachments.Add($att)
$smtp.Send($msg)
}
i get the error
[PS] C:\Windows\system32>C:\Scr ipts\Queue andMAilAle rtonQueueT hreshold2. ps1
New-PSSession : [xxx.com] Connecting to remote server xxx.com failed with the following
error message : WinRM cannot process the request. The following error occurred while using Kerberos
authentication: The computer xxx.com is unknown to Kerberos. Verify that the computer exists on the
network, that the name provided is spelled correctly, and that the Kerberos configuration for accessing the
computer is correct. The most common Kerberos configuration issue is that an SPN with the format
HTTP/xxx.com is not configured for the target. If Kerberos is not required, specify the Negotiate
authentication mechanism and resubmit the operation. For more information, see the about_Remote_Troubleshooti ng
Help topic.
At C:\Scripts\QueueandMAilAle rtonQueueT hreshold2. ps1:1 char:6
+ $s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https:// ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~
+ CategoryInfo : OpenError: (System.Manageme....Remote Runspace:R emoteRunsp ace) [New-PSSession], PS
RemotingTransportException
+ FullyQualifiedErrorId : NetworkPathNotFound,PSSess ionOpenFai led
Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Supply a non-null
argument and try the command again.
At C:\Scripts\QueueandMAilAle rtonQueueT hreshold2. ps1:2 char:18
+ Import-PSSession $s
+ ~~
+ CategoryInfo : InvalidData: (:) [Import-PSSession], ParameterBindingValidation Exception
+ FullyQualifiedErrorId : ParameterArgumentValidatio nError,Mic rosoft.Pow erShell.Co mmands.Imp ortPSSessi onCom
mand
Welcome to the Exchange Management Shell!
Full list of cmdlets: Get-Command
Only Exchange cmdlets: Get-ExCommand
Cmdlets that match a specific string: Help *<string>*
Get general help: Help
Get help for a cmdlet: Help <cmdlet name> or <cmdlet name> -?
Show quick reference guide: QuickRef
Exchange team blog: Get-ExBlog
Show full output for a command: <command> | Format-List
Tip of the day #45:
Forgot what the available parameters are on a cmdlet? Just use tab completion! Type:
Set-Mailbox -<tab>
When you type a hyphen (-) and then press the TAB key, you cycle through all the available parameters on the cmdl
et. Want to narrow your search? Type part of the parameter's name and then press the TAB key. Type:
Set-Mailbox -Prohibit<tab>
VERBOSE: Connecting to Mail.ISS.local
WARNING: Proxy creation has been skipped for the following command: 'Add-ADPermission, Add-AvailabilityAddressSpa
ce, Add-ContentFilterPhrase, Add-DatabaseAvailabilityGr oupServer, Add-DistributionGroupMembe r, Add-FederatedDomai
n, Add-IPAllowListEntry, Add-IPAllowListProvider, Add-IPBlockListEntry, Add-IPBlockListProvider, Add-MailboxDatab
aseCopy, Add-MailboxFolderPermissio n, Add-MailboxPermission, Add-ManagementRoleEntry, Add-PublicFolderAdministra t
ivePermission, Add-PublicFolderClientPerm ission, Add-RoleGroupMember, Clean-MailboxDatabase, Clear-ActiveSyncDevi
ce, Clear-TextMessagingAccount , Compare-TextMessagingVerif icationCod e, Connect-Mailbox, Disable-AddressListPaging
, Disable-CmdletExtensionAge nt, Disable-DistributionGroup, Disable-InboxRule, Disable-JournalRule, Disable-Mailbo
x, Disable-MailContact, Disable-MailPublicFolder, Disable-MailUser, Disable-OutlookAnywhere, Disable-OutlookProte
ctionRule, Disable-RemoteMailbox, Disable-ServiceEmailChanne l, Disable-TransportAgent, Disable-TransportRule, Dis
able-UMAutoAttendant, Disable-UMIPGateway, Disable-UMMailbox, Disable-UMServer, Dismount-Database, Enable-Address
ListPaging, Enable-AntispamUpdates, Enable-CmdletExtensionAgen t, Enable-DistributionGroup, Enable-ExchangeCertifi
cate, Enable-InboxRule, Enable-JournalRule, Enable-Mailbox, Enable-MailContact, Enable-MailPublicFolder, Enable-M
ailUser, Enable-OutlookAnywhere, Enable-OutlookProtectionRu le, Enable-RemoteMailbox, Enable-ServiceEmailChannel ,
Enable-TransportAgent, Enable-TransportRule, Enable-UMAutoAttendant, Enable-UMIPGateway, Enable-UMMailbox, Enable
-UMServer, Export-ActiveSyncLog, Export-AutoDiscoverConfig, Export-ExchangeCertificate , Export-JournalRuleCollect
ion, Export-MailboxDiagnosticLo gs, Export-Message, Export-RecipientDataProper ty, Export-TransportRuleCollec tion,
Export-UMCallDataRecord, Export-UMPrompt, Get-AcceptedDomain, Get-ActiveSyncDevice, Get-ActiveSyncDeviceAccess Rul
e, Get-ActiveSyncDeviceClass, Get-ActiveSyncDeviceStatis tics, Get-ActiveSyncMailboxPolic y, Get-ActiveSyncOrganiza
tionSettings, Get-ActiveSyncVirtualDirec tory, Get-AddressBookPolicy, Get-AddressList, Get-AdminAuditLogConfig, Ge
t-ADPermission, Get-ADServerSettings, Get-ADSite, Get-AdSiteLink, Get-AgentLog, Get-AuthRedirect, Get-Autodiscove
rVirtualDirectory, Get-AvailabilityAddressSpa ce, Get-AvailabilityConfig, Get-AvailabilityReportOuta ge, Get-Calend
arDiagnosticLog, Get-CalendarNotification, Get-CalendarProcessing, Get-CASMailbox, Get-ClientAccessArray, Get-Cli
entAccessServer, Get-CmdletExtensionAgent, Get-Contact, Get-ContentFilterConfig, Get-ContentFilterPhrase, Get-Dat
abaseAvailabilityGroup, Get-DatabaseAvailabilityGr oupNetwork , Get-DeliveryAgentConnector , Get-DetailsTemplate, Ge
t-DistributionGroup, Get-DistributionGroupMembe r, Get-DomainController, Get-DynamicDistributionGro up, Get-EcpVirt
ualDirectory, Get-EdgeSubscription, Get-EdgeSyncServiceConfig, Get-EmailAddressPolicy, Get-EventLogLevel, Get-Exc
hangeAssistanceConfig, Get-ExchangeCertificate, Get-ExchangeDiagnosticInfo , Get-ExchangeServer, Get-FailedContent
IndexDocuments, Get-FederatedDomainProof, Get-FederatedOrganizationI dentifier, Get-FederationInformation, Get-Fed
erationTrust, Get-ForeignConnector, Get-GlobalAddressList, Get-Group, Get-HybridConfiguration, Get-ImapSettings,
Get-InboxRule, Get-IPAllowListConfig, Get-IPAllowListEntry, Get-IPAllowListProvider, Get-IPAllowListProvidersCo nf
ig, Get-IPBlockListConfig, Get-IPBlockListEntry, Get-IPBlockListProvider, Get-IPBlockListProvidersCo nfig, Get-IRM
Configuration, Get-JournalRule, Get-LogonStatistics, Get-Mailbox, Get-MailboxAuditBypassAsso ciation, Get-MailboxA
utoReplyConfiguration, Get-MailboxCalendarConfigu ration, Get-MailboxCalendarFolder, Get-MailboxDatabase, Get-Mail
boxDatabaseCopyStatus, Get-MailboxFolder, Get-MailboxFolderPermissio n, Get-MailboxFolderStatistic s, Get-MailboxJu
nkEmailConfiguration, Get-MailboxMessageConfigur ation, Get-MailboxPermission, Get-MailboxRegionalConfigu ration, G
et-MailboxRestoreRequest, Get-MailboxRestoreRequestS tatistics, Get-MailboxSentItemsConfig uration, Get-MailboxServ
er, Get-MailboxSpellingConfigu ration, Get-MailboxStatistics, Get-MailContact, Get-MailPublicFolder, Get-MailUser,
Get-ManagedContentSettings , Get-ManagedFolder, Get-ManagedFolderMailboxPo licy, Get-ManagementRole, Get-Managemen
tRoleAssignment, Get-ManagementRoleEntry, Get-ManagementScope, Get-Message, Get-MessageCategory, Get-MessageClass
ification, Get-MessageTrackingLog, Get-MessageTrackingReport, Get-MoveRequest, Get-MoveRequestStatistics, Get-Net
workConnectionInfo, Get-OabVirtualDirectory, Get-OfflineAddressBook, Get-OrganizationalUnit, Get-OrganizationConf
ig, Get-OrganizationRelationsh ip, Get-OutlookAnywhere, Get-OutlookProtectionRule, Get-OutlookProvider, Get-OwaMai
lboxPolicy, Get-OwaVirtualDirectory, Get-PhysicalAvailabilityRe port, Get-PopSettings, Get-PowerShellVirtualDirec t
ory, Get-PublicFolder, Get-PublicFolderAdministra tivePermis sion, Get-PublicFolderClientPerm ission, Get-PublicFold
erDatabase, Get-PublicFolderItemStatis tics, Get-PublicFolderStatistics , Get-Queue, Get-ReceiveConnector, Get-Reci
pient, Get-RecipientFilterConfig, Get-RemoteDomain, Get-RemoteMailbox, Get-ResourceConfig, Get-RetentionPolicy, G
et-RetentionPolicyTag, Get-RMSTemplate, Get-RoleAssignmentPolicy, Get-RoleGroup, Get-RoleGroupMember, Get-Routing
GroupConnector, Get-RpcClientAccess, Get-SecurityPrincipal, Get-SendConnector, Get-SenderFilterConfig, Get-Sender
IdConfig, Get-SenderReputationConfig , Get-ServiceAvailabilityRep ort, Get-ServiceStatus, Get-SharingPolicy, Get-St
oreUsageStatistics, Get-SyncConfig, Get-SystemMessage, Get-TextMessagingAccount, Get-ThrottlingPolicy, Get-Thrott
lingPolicyAssociation, Get-TransportAgent, Get-TransportConfig, Get-TransportPipeline, Get-TransportRule, Get-Tra
nsportRuleAction, Get-TransportRulePredicate , Get-TransportServer, Get-Trust, Get-UMActiveCalls, Get-UMAutoAttend
ant, Get-UMCallDataRecord, Get-UMCallSummaryReport, Get-UMDialPlan, Get-UMHuntGroup, Get-UMIPGateway, Get-UMMailb
ox, Get-UMMailboxPIN, Get-UMMailboxPolicy, Get-UmServer, Get-User, Get-UserPrincipalNamesSuff ix, Get-WebServicesV
irtualDirectory, Get-X400AuthoritativeDomai n, Import-ExchangeCertificate , Import-JournalRuleCollecti on, Import-Re
cipientDataProperty, Import-TransportRuleCollec tion, Import-UMPrompt, Install-TransportAgent, Mount-Database, Mov
e-ActiveMailboxDatabase, Move-AddressList, Move-DatabasePath, Move-OfflineAddressBook, New-AcceptedDomain, New-Ac
tiveSyncDeviceAccessRule, New-ActiveSyncMailboxPolic y, New-ActiveSyncVirtualDirec tory, New-AddressBookPolicy, New
-AddressList, New-AdminAuditLogSearch, New-AuthRedirect, New-AutodiscoverVirtualDir ectory, New-AvailabilityReport
Outage, New-ClientAccessArray, New-DatabaseAvailabilityGr oup, New-DatabaseAvailabilityGr oupNetwork , New-DeliveryA
gentConnector, New-DistributionGroup, New-DynamicDistributionGro up, New-EcpVirtualDirectory, New-EdgeSubscription
, New-EdgeSyncServiceConfig, New-EmailAddressPolicy, New-ExchangeCertificate, New-FederationTrust, New-ForeignCon
nector, New-GlobalAddressList, New-HybridConfiguration, New-InboxRule, New-JournalRule, New-Mailbox, New-MailboxA
uditLogSearch, New-MailboxDatabase, New-MailboxFolder, New-MailboxRepairRequest, New-MailboxRestoreRequest, New-M
ailContact, New-MailMessage, New-MailUser, New-ManagedContentSettings , New-ManagedFolder, New-ManagedFolderMailbo
xPolicy, New-ManagementRole, New-ManagementRoleAssignme nt, New-ManagementScope, New-MessageClassification, New-Mo
veRequest, New-OabVirtualDirectory, New-OfflineAddressBook, New-OrganizationRelationsh ip, New-OutlookProtectionRu
le, New-OutlookProvider, New-OwaMailboxPolicy, New-OwaVirtualDirectory, New-PublicFolder, New-PublicFolderDatabas
e, New-PublicFolderDatabaseRe pairReques t, New-ReceiveConnector, New-RemoteDomain, New-RemoteMailbox, New-Retentio
nPolicy, New-RetentionPolicyTag, New-RoleAssignmentPolicy, New-RoleGroup, New-RoutingGroupConnector, New-RpcClien
tAccess, New-SendConnector, New-SharingPolicy, New-SystemMessage, New-ThrottlingPolicy, New-TransportRule, New-UM
AutoAttendant, New-UMDialPlan, New-UMHuntGroup, New-UMIPGateway, New-UMMailboxPolicy, New-WebServicesVirtualDire c
tory, New-X400AuthoritativeDomai n, Remove-AcceptedDomain, Remove-ActiveSyncDevice, Remove-ActiveSyncDeviceAcc essR
ule, Remove-ActiveSyncDeviceCla ss, Remove-ActiveSyncMailboxPo licy, Remove-ActiveSyncVirtualDi rectory, Remove-Addr
essBookPolicy, Remove-AddressList, Remove-ADPermission, Remove-AuthRedirect, Remove-AutodiscoverVirtual Directory,
Remove-AvailabilityAddress Space, Remove-AvailabilityReportO utage, Remove-ClientAccessArray, Remove-ContentFilter
Phrase, Remove-DatabaseAvailabilit yGroup, Remove-DatabaseAvailabilit yGroupNetw ork, Remove-DatabaseAvailabilit yGro
upServer, Remove-DeliveryAgentConnec tor, Remove-DistributionGroup, Remove-DistributionGroupMe mber, Remove-Dynamic
DistributionGroup, Remove-EcpVirtualDirectory , Remove-EdgeSubscription, Remove-EmailAddressPolicy, Remove-Exchang
eCertificate, Remove-FederatedDomain, Remove-FederationTrust, Remove-ForeignConnector, Remove-GlobalAddressList,
Remove-InboxRule, Remove-IPAllowListEntry, Remove-IPAllowListProvider , Remove-IPBlockListEntry, Remove-IPBlockLis
tProvider, Remove-JournalRule, Remove-Mailbox, Remove-MailboxDatabase, Remove-MailboxDatabaseCopy , Remove-Mailbox
FolderPermission, Remove-MailboxPermission, Remove-MailboxRestoreReque st, Remove-MailContact, Remove-MailUser, Re
move-ManagedContentSetting s, Remove-ManagedFolder, Remove-ManagedFolderMailbo xPolicy, Remove-ManagementRole, Remo
ve-ManagementRoleAssignmen t, Remove-ManagementRoleEntry , Remove-ManagementScope, Remove-Message, Remove-MessageCl
assification, Remove-MoveRequest, Remove-OabVirtualDirectory , Remove-OfflineAddressBook, Remove-OrganizationRelat
ionship, Remove-OutlookProtectionRu le, Remove-OutlookProvider, Remove-OwaMailboxPolicy, Remove-OwaVirtualDirector
y, Remove-PublicFolder, Remove-PublicFolderAdminis trativePer mission, Remove-PublicFolderClientP ermission, Remove-
PublicFolderDatabase, Remove-ReceiveConnector, Remove-RemoteDomain, Remove-RemoteMailbox, Remove-RetentionPolicy,
Remove-RetentionPolicyTag, Remove-RoleAssignmentPolic y, Remove-RoleGroup, Remove-RoleGroupMember, Remove-Routing
GroupConnector, Remove-RpcClientAccess, Remove-SendConnector, Remove-SharingPolicy, Remove-StoreMailbox, Remove-S
ystemMessage, Remove-ThrottlingPolicy, Remove-TransportRule, Remove-UMAutoAttendant, Remove-UMDialPlan, Remove-UM
HuntGroup, Remove-UMIPGateway, Remove-UMMailboxPolicy, Remove-WebServicesVirtualD irectory, Remove-X400Authoritati
veDomain, Restore-DatabaseAvailabili tyGroup, Restore-DetailsTemplate, Restore-Mailbox, Resume-MailboxDatabaseCopy
, Resume-MailboxExportReques t, Resume-MailboxRestoreReque st, Resume-Message, Resume-MoveRequest, Resume-PublicFol
derReplication, Resume-Queue, Retry-Queue, Search-AdminAuditLog, Search-MailboxAuditLog, Search-MessageTrackingRe
port, Send-TextMessagingVerifica tionCode, Set-AcceptedDomain, Set-ActiveSyncDeviceAccess Rule, Set-ActiveSyncMailb
oxPolicy, Set-ActiveSyncOrganization Settings, Set-ActiveSyncVirtualDirec tory, Set-AddressBookPolicy, Set-AddressL
ist, Set-AdminAuditLogConfig, Set-ADServerSettings, Set-ADSite, Set-AdSiteLink, Set-AuthRedirect, Set-Autodiscove
rVirtualDirectory, Set-AvailabilityConfig, Set-AvailabilityReportOuta ge, Set-CalendarNotification, Set-CalendarPr
ocessing, Set-CASMailbox, Set-ClientAccessArray, Set-ClientAccessServer, Set-CmdletExtensionAgent, Set-Contact, S
et-ContentFilterConfig, Set-DatabaseAvailabilityGr oup, Set-DatabaseAvailabilityGr oupNetwork , Set-DeliveryAgentCon
nector, Set-DetailsTemplate, Set-DistributionGroup, Set-DynamicDistributionGro up, Set-EcpVirtualDirectory, Set-Ed
geSyncServiceConfig, Set-EmailAddressPolicy, Set-EventLogLevel, Set-ExchangeAssistanceConf ig, Set-ExchangeServer,
Set-FederatedOrganizationI dentifier, Set-FederationTrust, Set-ForeignConnector, Set-GlobalAddressList, Set-Group
, Set-HybridConfiguration, Set-ImapSettings, Set-InboxRule, Set-IPAllowListConfig, Set-IPAllowListProvider, Set-I
PAllowListProvidersConfig, Set-IPBlockListConfig, Set-IPBlockListProvider, Set-IPBlockListProvidersCo nfig, Set-IR
MConfiguration, Set-JournalRule, Set-Mailbox, Set-MailboxAuditBypassAsso ciation, Set-MailboxAutoReplyConfig uratio
n, Set-MailboxCalendarConfigu ration, Set-MailboxCalendarFolder, Set-MailboxDatabase, Set-MailboxDatabaseCopy, Set
-MailboxFolderPermission, Set-MailboxJunkEmailConfig uration, Set-MailboxMessageConfigur ation, Set-MailboxRegional
Configuration, Set-MailboxRestoreRequest, Set-MailboxSentItemsConfig uration, Set-MailboxServer, Set-MailboxSpelli
ngConfiguration, Set-MailContact, Set-MailPublicFolder, Set-MailUser, Set-ManagedContentSettings , Set-ManagedFold
er, Set-ManagedFolderMailboxPo licy, Set-ManagementRoleAssignme nt, Set-ManagementRoleEntry, Set-ManagementScope, S
et-MessageClassification, Set-MoveRequest, Set-OabVirtualDirectory, Set-OfflineAddressBook, Set-OrganizationConfi
g, Set-OrganizationRelationsh ip, Set-OutlookAnywhere, Set-OutlookProtectionRule, Set-OutlookProvider, Set-OwaMail
boxPolicy, Set-OwaVirtualDirectory, Set-PopSettings, Set-PowerShellVirtualDirec tory, Set-PublicFolder, Set-Public
FolderDatabase, Set-ReceiveConnector, Set-RecipientFilterConfig, Set-RemoteDomain, Set-RemoteMailbox, Set-Resourc
eConfig, Set-RetentionPolicy, Set-RetentionPolicyTag, Set-RoleAssignmentPolicy, Set-RoleGroup, Set-RoutingGroupCo
nnector, Set-RpcClientAccess, Set-SendConnector, Set-SenderFilterConfig, Set-SenderIdConfig, Set-SenderReputation
Config, Set-SharingPolicy, Set-SystemMessage, Set-TextMessagingAccount, Set-ThrottlingPolicy, Set-ThrottlingPolic
yAssociation, Set-TransportAgent, Set-TransportConfig, Set-TransportRule, Set-TransportServer, Set-UMAutoAttendan
t, Set-UMDialPlan, Set-UMIPGateway, Set-UMMailbox, Set-UMMailboxPIN, Set-UMMailboxPolicy, Set-UmServer, Set-User,
Set-WebServicesVirtualDire ctory, Set-X400AuthoritativeDomai n, Start-DatabaseAvailability Group, Start-EdgeSynchro
nization, Start-ManagedFolderAssista nt, Start-RetentionAutoTagLear ning, Stop-DatabaseAvailabilityG roup, Stop-Mana
gedFolderAssistant, Suspend-MailboxDatabaseCop y, Suspend-MailboxRestoreRequ est, Suspend-Message, Suspend-MoveRequ
est, Suspend-PublicFolderReplic ation, Suspend-Queue, Test-ActiveSyncConnectivit y, Test-ArchiveConnectivity, Test-
AssistantHealth, Test-CalendarConnectivity, Test-EcpConnectivity, Test-EdgeSynchronization, Test-ExchangeSearch,
Test-FederationTrust, Test-FederationTrustCertif icate, Test-ImapConnectivity, Test-IPAllowListProvider, Test-IPBl
ockListProvider, Test-IRMConfiguration, Test-Mailflow, Test-MAPIConnectivity, Test-MRSHealth, Test-OrganizationRe
lationship, Test-OutlookConnectivity, Test-OutlookWebServices, Test-OwaConnectivity, Test-PopConnectivity, Test-P
owerShellConnectivity, Test-ReplicationHealth, Test-SenderId, Test-ServiceHealth, Test-SmtpConnectivity, Test-Sys
temHealth, Test-UMConnectivity, Test-WebServicesConnectivi ty, Uninstall-TransportAgent, Update-AddressList, Updat
e-DistributionGroupMember, Update-EmailAddressPolicy, Update-FileDistributionSer vice, Update-GlobalAddressList, U
pdate-HybridConfiguration, Update-MailboxDatabaseCopy , Update-OfflineAddressBook, Update-PublicFolder, Update-Pub
licFolderHierarchy, Update-Recipient, Update-RoleGroupMember, Update-SafeList, Write-AdminAuditLog', because it w
ould shadow an existing local command. Use the AllowClobber parameter if you want to shadow existing local comma
nds.
WARNING: Can't generate Export-Module for the current session using Import-PSSession.
VERBOSE: Connected to Mail.ISS.local.
[PS] C:\Windows\system32>
$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://xxx.com/PowerShell/ -Authentication Kerberos
Import-PSSession $s
Add-PSSnapin Microsoft.Exchange.Managem
. $env:ExchangeInstallPath\b
Connect-ExchangeServer -auto
$threshold = 10
$filename = "c:\Temp\QueueStats.txt"
Start-Sleep -s 10
if (Get-ExchangeServer | Where { $_.Name -eq "Mail" } | get-queue | Where-Object { $_.MessageCount -gt $threshold })
{
Get-ExchangeServer | Where { $_.Name -eq "Mail" } | get-queue | Where-Object { $_.MessageCount -gt $threshold } | Format-Table -Wrap -AutoSize | out-file -filepath c:\Temp\QueueStats.txt
Start-Sleep -s 10
$smtpServer = "10.0.1.6"
Write-Host "Connecting to $smtpServer"
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($filen
$smtp = new-object Net.Mail.SmtpClient($smtpS
$msg.From = "rsharma@xxx.com"
$msg.To.Add("rsharma@xxx.c
$msg.To.Add("rprasad@xxx.c
$msg.Subject = "EXCHANGE SERVER - CAS THRESHOLD ALERT!!!"
$msg.Body = "Please see attached queue log file for queue information. "
$msg.Attachments.Add($att)
$smtp.Send($msg)
}
i get the error
[PS] C:\Windows\system32>C:\Scr
New-PSSession : [xxx.com] Connecting to remote server xxx.com failed with the following
error message : WinRM cannot process the request. The following error occurred while using Kerberos
authentication: The computer xxx.com is unknown to Kerberos. Verify that the computer exists on the
network, that the name provided is spelled correctly, and that the Kerberos configuration for accessing the
computer is correct. The most common Kerberos configuration issue is that an SPN with the format
HTTP/xxx.com is not configured for the target. If Kerberos is not required, specify the Negotiate
authentication mechanism and resubmit the operation. For more information, see the about_Remote_Troubleshooti
Help topic.
At C:\Scripts\QueueandMAilAle
+ $s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https:// ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.Manageme....Remote
RemotingTransportException
+ FullyQualifiedErrorId : NetworkPathNotFound,PSSess
Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Supply a non-null
argument and try the command again.
At C:\Scripts\QueueandMAilAle
+ Import-PSSession $s
+ ~~
+ CategoryInfo : InvalidData: (:) [Import-PSSession], ParameterBindingValidation
+ FullyQualifiedErrorId : ParameterArgumentValidatio
mand
Welcome to the Exchange Management Shell!
Full list of cmdlets: Get-Command
Only Exchange cmdlets: Get-ExCommand
Cmdlets that match a specific string: Help *<string>*
Get general help: Help
Get help for a cmdlet: Help <cmdlet name> or <cmdlet name> -?
Show quick reference guide: QuickRef
Exchange team blog: Get-ExBlog
Show full output for a command: <command> | Format-List
Tip of the day #45:
Forgot what the available parameters are on a cmdlet? Just use tab completion! Type:
Set-Mailbox -<tab>
When you type a hyphen (-) and then press the TAB key, you cycle through all the available parameters on the cmdl
et. Want to narrow your search? Type part of the parameter's name and then press the TAB key. Type:
Set-Mailbox -Prohibit<tab>
VERBOSE: Connecting to Mail.ISS.local
WARNING: Proxy creation has been skipped for the following command: 'Add-ADPermission, Add-AvailabilityAddressSpa
ce, Add-ContentFilterPhrase, Add-DatabaseAvailabilityGr
n, Add-IPAllowListEntry, Add-IPAllowListProvider, Add-IPBlockListEntry, Add-IPBlockListProvider, Add-MailboxDatab
aseCopy, Add-MailboxFolderPermissio
ivePermission, Add-PublicFolderClientPerm
ce, Clear-TextMessagingAccount
, Disable-CmdletExtensionAge
x, Disable-MailContact, Disable-MailPublicFolder, Disable-MailUser, Disable-OutlookAnywhere, Disable-OutlookProte
ctionRule, Disable-RemoteMailbox, Disable-ServiceEmailChanne
able-UMAutoAttendant, Disable-UMIPGateway, Disable-UMMailbox, Disable-UMServer, Dismount-Database, Enable-Address
ListPaging, Enable-AntispamUpdates, Enable-CmdletExtensionAgen
cate, Enable-InboxRule, Enable-JournalRule, Enable-Mailbox, Enable-MailContact, Enable-MailPublicFolder, Enable-M
ailUser, Enable-OutlookAnywhere, Enable-OutlookProtectionRu
Enable-TransportAgent, Enable-TransportRule, Enable-UMAutoAttendant, Enable-UMIPGateway, Enable-UMMailbox, Enable
-UMServer, Export-ActiveSyncLog, Export-AutoDiscoverConfig,
ion, Export-MailboxDiagnosticLo
Export-UMCallDataRecord, Export-UMPrompt, Get-AcceptedDomain, Get-ActiveSyncDevice, Get-ActiveSyncDeviceAccess
e, Get-ActiveSyncDeviceClass,
tionSettings, Get-ActiveSyncVirtualDirec
t-ADPermission, Get-ADServerSettings, Get-ADSite, Get-AdSiteLink, Get-AgentLog, Get-AuthRedirect, Get-Autodiscove
rVirtualDirectory, Get-AvailabilityAddressSpa
arDiagnosticLog, Get-CalendarNotification, Get-CalendarProcessing, Get-CASMailbox, Get-ClientAccessArray, Get-Cli
entAccessServer, Get-CmdletExtensionAgent, Get-Contact, Get-ContentFilterConfig, Get-ContentFilterPhrase, Get-Dat
abaseAvailabilityGroup, Get-DatabaseAvailabilityGr
t-DistributionGroup, Get-DistributionGroupMembe
ualDirectory, Get-EdgeSubscription, Get-EdgeSyncServiceConfig,
hangeAssistanceConfig, Get-ExchangeCertificate, Get-ExchangeDiagnosticInfo
IndexDocuments, Get-FederatedDomainProof, Get-FederatedOrganizationI
erationTrust, Get-ForeignConnector, Get-GlobalAddressList, Get-Group, Get-HybridConfiguration, Get-ImapSettings,
Get-InboxRule, Get-IPAllowListConfig, Get-IPAllowListEntry, Get-IPAllowListProvider, Get-IPAllowListProvidersCo
ig, Get-IPBlockListConfig, Get-IPBlockListEntry, Get-IPBlockListProvider, Get-IPBlockListProvidersCo
Configuration, Get-JournalRule, Get-LogonStatistics, Get-Mailbox, Get-MailboxAuditBypassAsso
utoReplyConfiguration, Get-MailboxCalendarConfigu
boxDatabaseCopyStatus, Get-MailboxFolder, Get-MailboxFolderPermissio
nkEmailConfiguration, Get-MailboxMessageConfigur
et-MailboxRestoreRequest, Get-MailboxRestoreRequestS
er, Get-MailboxSpellingConfigu
Get-ManagedContentSettings
tRoleAssignment, Get-ManagementRoleEntry, Get-ManagementScope, Get-Message, Get-MessageCategory, Get-MessageClass
ification, Get-MessageTrackingLog, Get-MessageTrackingReport,
workConnectionInfo, Get-OabVirtualDirectory, Get-OfflineAddressBook, Get-OrganizationalUnit, Get-OrganizationConf
ig, Get-OrganizationRelationsh
lboxPolicy, Get-OwaVirtualDirectory, Get-PhysicalAvailabilityRe
ory, Get-PublicFolder, Get-PublicFolderAdministra
erDatabase, Get-PublicFolderItemStatis
pient, Get-RecipientFilterConfig,
et-RetentionPolicyTag, Get-RMSTemplate, Get-RoleAssignmentPolicy, Get-RoleGroup, Get-RoleGroupMember, Get-Routing
GroupConnector, Get-RpcClientAccess, Get-SecurityPrincipal, Get-SendConnector, Get-SenderFilterConfig, Get-Sender
IdConfig, Get-SenderReputationConfig
oreUsageStatistics, Get-SyncConfig, Get-SystemMessage, Get-TextMessagingAccount, Get-ThrottlingPolicy, Get-Thrott
lingPolicyAssociation, Get-TransportAgent, Get-TransportConfig, Get-TransportPipeline, Get-TransportRule, Get-Tra
nsportRuleAction, Get-TransportRulePredicate
ant, Get-UMCallDataRecord, Get-UMCallSummaryReport, Get-UMDialPlan, Get-UMHuntGroup, Get-UMIPGateway, Get-UMMailb
ox, Get-UMMailboxPIN, Get-UMMailboxPolicy, Get-UmServer, Get-User, Get-UserPrincipalNamesSuff
irtualDirectory, Get-X400AuthoritativeDomai
cipientDataProperty, Import-TransportRuleCollec
e-ActiveMailboxDatabase, Move-AddressList, Move-DatabasePath, Move-OfflineAddressBook, New-AcceptedDomain, New-Ac
tiveSyncDeviceAccessRule, New-ActiveSyncMailboxPolic
-AddressList, New-AdminAuditLogSearch, New-AuthRedirect, New-AutodiscoverVirtualDir
Outage, New-ClientAccessArray, New-DatabaseAvailabilityGr
gentConnector, New-DistributionGroup, New-DynamicDistributionGro
, New-EdgeSyncServiceConfig,
nector, New-GlobalAddressList, New-HybridConfiguration, New-InboxRule, New-JournalRule, New-Mailbox, New-MailboxA
uditLogSearch, New-MailboxDatabase, New-MailboxFolder, New-MailboxRepairRequest, New-MailboxRestoreRequest,
ailContact, New-MailMessage, New-MailUser, New-ManagedContentSettings
xPolicy, New-ManagementRole, New-ManagementRoleAssignme
veRequest, New-OabVirtualDirectory, New-OfflineAddressBook, New-OrganizationRelationsh
le, New-OutlookProvider, New-OwaMailboxPolicy, New-OwaVirtualDirectory, New-PublicFolder, New-PublicFolderDatabas
e, New-PublicFolderDatabaseRe
nPolicy, New-RetentionPolicyTag, New-RoleAssignmentPolicy, New-RoleGroup, New-RoutingGroupConnector,
tAccess, New-SendConnector, New-SharingPolicy, New-SystemMessage, New-ThrottlingPolicy, New-TransportRule, New-UM
AutoAttendant, New-UMDialPlan, New-UMHuntGroup, New-UMIPGateway, New-UMMailboxPolicy, New-WebServicesVirtualDire
tory, New-X400AuthoritativeDomai
ule, Remove-ActiveSyncDeviceCla
essBookPolicy, Remove-AddressList, Remove-ADPermission, Remove-AuthRedirect, Remove-AutodiscoverVirtual
Remove-AvailabilityAddress
Phrase, Remove-DatabaseAvailabilit
upServer, Remove-DeliveryAgentConnec
DistributionGroup, Remove-EcpVirtualDirectory
eCertificate, Remove-FederatedDomain, Remove-FederationTrust, Remove-ForeignConnector, Remove-GlobalAddressList,
Remove-InboxRule, Remove-IPAllowListEntry, Remove-IPAllowListProvider
tProvider, Remove-JournalRule, Remove-Mailbox, Remove-MailboxDatabase, Remove-MailboxDatabaseCopy
FolderPermission, Remove-MailboxPermission, Remove-MailboxRestoreReque
move-ManagedContentSetting
ve-ManagementRoleAssignmen
assification, Remove-MoveRequest, Remove-OabVirtualDirectory
ionship, Remove-OutlookProtectionRu
y, Remove-PublicFolder, Remove-PublicFolderAdminis
PublicFolderDatabase, Remove-ReceiveConnector, Remove-RemoteDomain, Remove-RemoteMailbox, Remove-RetentionPolicy,
Remove-RetentionPolicyTag,
GroupConnector, Remove-RpcClientAccess, Remove-SendConnector, Remove-SharingPolicy, Remove-StoreMailbox, Remove-S
ystemMessage, Remove-ThrottlingPolicy, Remove-TransportRule, Remove-UMAutoAttendant, Remove-UMDialPlan, Remove-UM
HuntGroup, Remove-UMIPGateway, Remove-UMMailboxPolicy, Remove-WebServicesVirtualD
veDomain, Restore-DatabaseAvailabili
, Resume-MailboxExportReques
derReplication, Resume-Queue, Retry-Queue, Search-AdminAuditLog, Search-MailboxAuditLog, Search-MessageTrackingRe
port, Send-TextMessagingVerifica
oxPolicy, Set-ActiveSyncOrganization
ist, Set-AdminAuditLogConfig, Set-ADServerSettings, Set-ADSite, Set-AdSiteLink, Set-AuthRedirect, Set-Autodiscove
rVirtualDirectory, Set-AvailabilityConfig, Set-AvailabilityReportOuta
ocessing, Set-CASMailbox, Set-ClientAccessArray, Set-ClientAccessServer, Set-CmdletExtensionAgent, Set-Contact, S
et-ContentFilterConfig, Set-DatabaseAvailabilityGr
nector, Set-DetailsTemplate, Set-DistributionGroup, Set-DynamicDistributionGro
geSyncServiceConfig, Set-EmailAddressPolicy, Set-EventLogLevel, Set-ExchangeAssistanceConf
Set-FederatedOrganizationI
, Set-HybridConfiguration, Set-ImapSettings, Set-InboxRule, Set-IPAllowListConfig, Set-IPAllowListProvider, Set-I
PAllowListProvidersConfig,
MConfiguration, Set-JournalRule, Set-Mailbox, Set-MailboxAuditBypassAsso
n, Set-MailboxCalendarConfigu
-MailboxFolderPermission, Set-MailboxJunkEmailConfig
Configuration, Set-MailboxRestoreRequest,
ngConfiguration, Set-MailContact, Set-MailPublicFolder, Set-MailUser, Set-ManagedContentSettings
er, Set-ManagedFolderMailboxPo
et-MessageClassification, Set-MoveRequest, Set-OabVirtualDirectory, Set-OfflineAddressBook, Set-OrganizationConfi
g, Set-OrganizationRelationsh
boxPolicy, Set-OwaVirtualDirectory, Set-PopSettings, Set-PowerShellVirtualDirec
FolderDatabase, Set-ReceiveConnector, Set-RecipientFilterConfig,
eConfig, Set-RetentionPolicy, Set-RetentionPolicyTag, Set-RoleAssignmentPolicy, Set-RoleGroup, Set-RoutingGroupCo
nnector, Set-RpcClientAccess, Set-SendConnector, Set-SenderFilterConfig, Set-SenderIdConfig, Set-SenderReputation
Config, Set-SharingPolicy, Set-SystemMessage, Set-TextMessagingAccount, Set-ThrottlingPolicy, Set-ThrottlingPolic
yAssociation, Set-TransportAgent, Set-TransportConfig, Set-TransportRule, Set-TransportServer, Set-UMAutoAttendan
t, Set-UMDialPlan, Set-UMIPGateway, Set-UMMailbox, Set-UMMailboxPIN, Set-UMMailboxPolicy, Set-UmServer, Set-User,
Set-WebServicesVirtualDire
nization, Start-ManagedFolderAssista
gedFolderAssistant, Suspend-MailboxDatabaseCop
est, Suspend-PublicFolderReplic
AssistantHealth, Test-CalendarConnectivity,
Test-FederationTrust, Test-FederationTrustCertif
ockListProvider, Test-IRMConfiguration, Test-Mailflow, Test-MAPIConnectivity, Test-MRSHealth, Test-OrganizationRe
lationship, Test-OutlookConnectivity, Test-OutlookWebServices, Test-OwaConnectivity, Test-PopConnectivity, Test-P
owerShellConnectivity, Test-ReplicationHealth, Test-SenderId, Test-ServiceHealth, Test-SmtpConnectivity, Test-Sys
temHealth, Test-UMConnectivity, Test-WebServicesConnectivi
e-DistributionGroupMember,
pdate-HybridConfiguration,
licFolderHierarchy, Update-Recipient, Update-RoleGroupMember, Update-SafeList, Write-AdminAuditLog', because it w
ould shadow an existing local command. Use the AllowClobber parameter if you want to shadow existing local comma
nds.
WARNING: Can't generate Export-Module for the current session using Import-PSSession.
VERBOSE: Connected to Mail.ISS.local.
[PS] C:\Windows\system32>
ASKER
still doesnt work
Are you successfully connecting to exchange or not?
also does the authentication account you are using for Kerberos authentication in the script have permissions on the exchange server?
ASKER
I am running this on exchange server and i am the domain admin. kerbros authentication may not be enabled . i will check this and get back
ASKER
doesn't work
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
worked
Add-PSSnapin Microsoft.Exchange.Managem
. $env:ExchangeInstallPath\b
Connect-ExchangeServer -auto
Also it's http://servername/PowerShell not "https" if local.