.NET Framework - Powershell.exe troubles with spaces, quotes, and arguments

Asked By winnt
20-Nov-09 04:55 PM
I need to run a PowerShell script from a command prompt, but am having
trouble.  This command works fine inside PowerShell:

Get-WMIObject MSCluster_ResourceGroup -ComputerName MYEXCHANGE01 -Namespace
root\mscluster -filter "name='Cluster Group'" | Format-Table __Server

When I launch it from a command line:

powershell.exe -psconsolefile "D:\Program Files\Microsoft\Exchange
Server\bin\exshell.psc1" -command Get-WMIObject MSCluster_ResourceGroup
-ComputerName MYEXCHANGE01 -Namespace root\mscluster -filter "name='Cluster
Group'" | Format-Table __Server

I get:

'Format-Table' is not recognized as an internal or external command,
operable program or batch file.

How can I get this to work?

Thanks.
Exchange Server
(1)
WMIObject
(1)
MSCluster
(1)
ResourceGroup
(1)
Psconsolefile
(1)
MYEXCHANGE01
(1)
  Larry__Weiss replied to winnt
20-Nov-09 05:18 PM
Try (all on one line of course)

powershell.exe -psconsolefile "D:\Program Files\Microsoft\Exchange
Server\bin\exshell.psc1" -command "Get-WMIObject MSCluster_ResourceGroup
-ComputerName MYEXCHANGE01 -Namespace root\mscluster -filter name='Cluster
Group' | Format-Table __Server"

The main idea is to wrap double quotes around the PowerShell command, and not
using them inside the PowerShell command.  The pipe was being interpreted at the
cmd.exe level and not the PowerShell level.

- Larry
Create New Account
help
Wmi error exchange 2003 .NET Framework after months of working fine the following suddenly broke PS C: \ SCRIPTS \ Exchange> get-wmiobject -namespace "ROOT \ MicrosoftExchangeV2" -computername "XXXXX" -class "Exchange_SMTPLink" | Ft linkname, Messagecount -hidetableheaders -auto error reads as follows Get-WmiObject : Provider load failure At C: \ SCRIPTS \ Exchange \ Get-ExchangeMessageQs.ps1:1 char:14 + get wmiobject <<<< -namespace "ROOT \ MicrosoftExchangeV2" -computername -hidetableheaders -auto any ideas ??? Powershell Discussions SMTPLink (1) PowerGadgets (1) Messagecount (1) Windows (1) Hidetableheaders (1) Locallyyes (1) Wmiobject (1) Linkname (1) Are you able to run these locally on the Exchange server itself? Just for fun, try any regular WMI call like: get-wmiobject -computername "ABC
Hi all, I've got a script that runs each morning to gather from each Exchange server its name, Mailboxes on server, sizes, and so forth. Now I get a csv file from each server with date which is nice, but was wondering how I could setup to just receive using. . . - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- $day = Get-Date -UFormat "%Y%m%d" $computers = "exch02", "exch03", "exch04" foreach ($computer in $computers) { Get-Wmiobject -namespace root \ MicrosoftExchangeV2 -class Exchange_Mailbox -computer $computer | sort-object -ascend MailboxDisplayName | select-object MailboxDisplayName, ServerName I'll still try and find info online. . .somewhere. Thanks all j0seg Powershell Discussions SQL Server (1) MailboxDisplayName (1) StorageGroupName (1) TotalItems (1) ServerName (1) StoreName (1) UFormat (1) PhD (1 work: $day = Get-Date -UFormat "%Y%m%d" $computers = "exch02", "exch03", "exch04" foreach ($computer in $computers) { Get-Wmiobject -namespace root \ MicrosoftExchangeV2 -class Exchange_Mailbox -computer $computer | sort-object -ascend MailboxDisplayName | select-object MailboxDisplayName, ServerName out \ $computer-$day.csv - - Tom - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS SQL Server MVP Toronto, ON Canada https: / / mvp.support.microsoft.com / profile / Tom.Moreau Hi all, I
WMI and Exch2003 .NET Framework Hey all, Short version: Get-WMIObject returns multiple Exchange 2003 queues going to the same destination, where the system manager and everything else I I keep coming up empty. . . I've got several scripts we use for monitoring our Exchange 2003 servers and keep running into something that I can't figure out. The following command returns a list of queues on our Exchange server (all one line): Get-wmiobject -class exchange_SMTPQueue -Namespace ROOT \ MicrosoftExchangev2 -ComputerName $objItem | Select-Object VirtualMachine, LinkName, QueueName, MessageCount, Size | Where you've assigned $objItem a servername), but I frequently find that a "single" queue in Exchange gets displayed as multiple queues in PoSH. . . I know this is really due to WMI, not PoSH, but the WMI and Exchange groups had no help to offer. Why is WMI returning the same queue multiple times
exchange 2003 with powershell .NET Framework i understand exchange 2007 supports powershell, but i m still using exchnage 2003. Can i use powershell to perform admin tasks on exchange 2003 ? Powershell Discussions PowerGUI (1) ESFMZj (1) PowerGadgets (1) Poshoholic (1) Siddaway (1) Windows (1 Firewalls (1) Wmiobject (1) Yes, you can use WMI to manage Exchange 2003. Now, as long as the proper class exits. . . What are you looking to do also use the Quest AD cmdlets if you need to do something AD related on Exchange 2003 AD objects. - - Kirk Munro [MVP] Poshoholic http: / / www.poshoholic.com Some of the Exchange 2007 cmdlets will work against Ex 2003 servers if you have a mixed environment - - Richard Group: http: / / www.get-psuguk.org.uk example : Can i check the queue in the exchange 2003 or how many emails per mailbox in exchange 2003 ? Are there samples ? This is