problem loadin snapin
hello.
i got simple script:
'start' | set-content 'c:\scripts\log.txt'
if ( (get-pssnapin -name microsoft.exchange.management.powershell.e2010 -erroraction silentlycontinue) -eq $null ){
'in if pre add' | add-content 'c:\scripts\log.txt'
add-pssnapin -name microsoft.exchange.management.powershell.e2010
'end if' | add-content 'c:\scripts\log.txt'
}
if run intercative user (in remote dsktop), went well. if run zabbix agent (run service local system account) script dies , "end if" string not write file. call zabbix: powershell.exe -file c:\scripts\discoverymbs.ps1
adding
get-pssnapin -registered | add-content 'c:\scripts\snapin.txt'
before if block, list written file:
microsoft.exchange.management.powershell.e2010
microsoft.exchange.management.powershell.setup
microsoft.exchange.management.powershell.support
so don't understand why cannot run add-pssnapin , script dies. try catch exception, doesn't work, script dies on add-pssnapin call
giovanni
for running scripts exchange server directly works best me:
function load-exchangeenvironment { . "$env:exchangeinstallpath\bin\remoteexchange.ps1" connect-exchangeserver -auto }
Windows Server > Windows PowerShell
Comments
Post a Comment