Показать полную графическую версию : [решено] Выполнение Exchange команд
Доброго дня.
Есть сервер c Exchange 2010 SP2.
Нужно на нём выполнять скрипт: Test-Mailflow -TargetEmailAddress username@domain.name
Дело в том, что сам PS такую команду не знает. Её знает PS для Exchange 2010...
И я никак не пойму, что указывать в планировщике, что бы запустить скрипт именно в PS Exchange.
Спасибо.
Добавить в скрипт загрузку Snapin:
add-pssnapin Microsoft.Exchange.Management.PowerShell.Admin
или подгрузить startup скрипт:
%programfiles%\Microsoft\Exchange Server\bin\Exchange.ps1
Kazun, извините, я не совсем понял.
вначале попробовал с самом ПС выполнить:
PS C:\> & 'C:\Program Files\Microsoft\Exchange Server\V14\Bin\Exchange.ps1'
The term 'Set-ADServerSettings' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Program Files\Microsoft\Exchange Server\V14\Bin\Exchange.ps1:48 char:21
+ Set-ADServerSettings <<<< -ViewEntireForest $false -WarningAction SilentlyContinue
+ CategoryInfo : ObjectNotFound: (Set-ADServerSettings:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Welcome to the Exchange Management Shell!
Full list of cmdlets: get-command
Only Exchange cmdlets: get-excommand
Cmdlets for a specific role: get-help -role *CAS* or *Mailbox*
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 cmd: <cmd> | format-list
Tip of the day #6:
Want to see the members of a dynamic distribution group that has a custom filter? Just use the Get-Recipient cmdlet. Typ
e:
$DDG = Get-DynamicDistributionGroup "Contoso Marketing Managers"
Get-Recipient -RecipientPreviewFilter $DDG.RecipientFilter
и всё равно:
PS C:\> Test-Mailflow -TargetEmailAddress username@domain.name
The term 'Test-Mailflow' is not recognized as the name of a cmdlet, function, script file, or operable program. Check t
he spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:14
+ Test-Mailflow <<<< -TargetEmailAddress username@domain.name
+ CategoryInfo : ObjectNotFound: (Test-Mailflow:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PowerShell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\V14\Bin\ExShell.psc1" -Command ". 'c:\scripts\Script.ps1'"
Kazun, Спасибо! только и этот скрипт не запускается, а открывает файл. прочитал про ExecutionPolicy
PS C:\Windows\system32> get-ExecutionPolicy
RemoteSigned
но всё равно локальный скрипт не запускает как надо...
Вывод скрипта:
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Test-Mailflow -TargetEmailAddress username@domain.name
Более подробно:
http://www.mikepfeiffer.net/2010/02/creating-scheduled-tasks-for-exchange-2010-powershell-scripts/
http://www.mikepfeiffer.net/2010/02/managing-exchange-2010-with-remote-powershell/
Сделал так:
- в аргументах к команде C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe добавил:
-PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\V14\Bin\ExShell.psc1" -Command ". 'D:\script\mailflow.ps1'"
где в mailflow.ps1:
Test-Mailflow -TargetEmailAddress user.name@domain.name
собственно 4-ый пост, но без картинок из 6-го я не понял...
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.