Thursday, April 3, 2014
How to use powershell command from vbs script
Edit in MyVBSScript:
Set objShell = CreateObject("Wscript.shell")
objShell.run("powershell -file C:\Users\bla_bla\Documents\powershell.ps1")
Where in powershell.ps1 file this is an example of what it can contain:
$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://nameserver.domain/PowerShell/ -Authentication Kerberos
Import-PSSession $s
Get-MailboxDatabase gb* -Status | select name,mounted > C:\Users\bla_bla\Documents\command.txt
Remove-PSSession $s (this is important for close powershell sessions)
Powershell script to monitor Backup Processes and then send the alert to OVO Manager:
$processes= Get-Process Ese_bar,mbx_bar,E2010_bar
$processes > C:\Users\bla_bla\Documents\out_processes.txt
$processes
$m= $processes| measure
$m
$a=$m.count
$a
if ($a -eq 0) {$OVOMSG = "There are $a backup processes and DB is in False status"
& 'C:\Program Files\HP\HP BTO Software\bin\win64\opcmsg.exe' --ArgumentList "a=MSExchange" "o=Database" "msg_t=$OVOMSG" "s=critical" "msg_grp=E-mail"}
else {$OVOMSG = "There are $a backup processes $processes and DB is in False status"
& 'C:\Program Files\HP\HP BTO Software\bin\win64\opcmsg.exe' --ArgumentList "a=MSExchange" "o=Database" "msg_t=$OVOMSG" "s=major" "msg_grp=E-mail"}
Labels:
OVOW
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment