What do you mean by your first sentence?

Regards,

Michael B. Smith
Consultant and Exchange MVP
http://TheEssentialExchange.com

From: Campbell, Rob [mailto:rob_campb...@centraltechnology.net]
Sent: Friday, October 22, 2010 2:53 PM
To: MS-Exchange Admin Issues
Subject: RE: PS script in batch troubleshooting

You can't call a .ps1 file directly from CMD.

See if this works better:

powershell.exe -command "add-pssnapin 
microsoft.exchange.management.powershell.admin; $date = Get-date ; $shortdate = 
$date.ToShortdateString() ; get-messagetrackinglog -messagesubject:"NWEA 
password" -Start $shortdate  | Select sender,messagesubject | ft -auto"


From: David Lum [mailto:david....@nwea.org]
Sent: Friday, October 22, 2010 1:44 PM
To: MS-Exchange Admin Issues
Subject: RE: PS script in batch troubleshooting

Thanks.
Exchange 2007.

Can I have a .CMD call a PS1 file and call it good?

Dave

From: Campbell, Rob [mailto:rob_campb...@centraltechnology.net]
Sent: Friday, October 22, 2010 11:27 AM
To: MS-Exchange Admin Issues
Subject: RE: PS script in batch troubleshooting

Nope.

I believe the problem is that when you run it from the PS command line, it's 
actually being run from an EMS command line.  The EMS is a generic Powershell 
console, with the modules or snapins (depending on your Exchange version) 
installed that implement the exchange specific cmdlets.

Since you're calling a generic Powershell instance from cmd, it doesn't have 
those cmdlets, so it doesn't understand "get-messagetrackinglog".

What version of Exchange are you running?

From: David Lum [mailto:david....@nwea.org]
Sent: Friday, October 22, 2010 1:21 PM
To: MS-Exchange Admin Issues
Subject: PS script in batch troubleshooting

This works at the PS command line:
$date = Get-date ; $shortdate = $date.ToShortdateString() ; 
get-messagetrackinglog -messagesubject:"NWEA password" -Start $shortdate  | 
Select sender,messagesubject | ft -auto

This does NOT work in a .CMD file (simply adds "powershell.exe -command" to the 
front):
powershell.exe -command "$date = Get-date ; $shortdate = 
$date.ToShortdateString() ; get-messagetrackinglog -messagesubject:"NWEA 
password" -Start $shortdate  | Select sender,messagesubject  | ft -auto

Error message is "The term 'get-messagetrackinglog' is not recognized as a 
cmdlet, function, operable program, or script file. Verify the term and try 
again."

Is my date string in front messing it up?
David Lum // SYSTEMS ENGINEER
NORTHWEST EVALUATION ASSOCIATION
(Desk) 971.222.1025 // (Cell) 503.267.9764


---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com>
with the body: unsubscribe exchangelist

**************************************************************************************************

Note:

The information contained in this message may be privileged and confidential and

protected from disclosure.  If the reader of this message is not the intended

recipient, or an employee or agent responsible for delivering this message to

the intended recipient, you are hereby notified that any dissemination,

distribution or copying of this communication is strictly prohibited. If you

have received this communication in error, please notify us immediately by

replying to the message and deleting it from your computer.

**************************************************************************************************

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com>
with the body: unsubscribe exchangelist

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com>
with the body: unsubscribe exchangelist

**************************************************************************************************

Note:

The information contained in this message may be privileged and confidential and

protected from disclosure.  If the reader of this message is not the intended

recipient, or an employee or agent responsible for delivering this message to

the intended recipient, you are hereby notified that any dissemination,

distribution or copying of this communication is strictly prohibited. If you

have received this communication in error, please notify us immediately by

replying to the message and deleting it from your computer.

**************************************************************************************************

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
listmana...@lyris.sunbeltsoftware.com<mailto:listmana...@lyris.sunbeltsoftware.com>
with the body: unsubscribe exchangelist

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe exchangelist

Reply via email to